Example #1
0
    def __init__(self, data, ax, prefs, *args, **kw):

        PlotBase.__init__(self, data, ax, prefs, *args, **kw)
        if type(data) == types.DictType:
            self.gdata = GraphData(data)
        elif type(data) == types.InstanceType and data.__class__ == GraphData:
            self.gdata = data
        if self.prefs.has_key('span'):
            self.width = self.prefs['span']
        else:
            self.width = 1.0
            if self.gdata.key_type == "time":
                nKeys = self.gdata.getNumberOfKeys()
                self.width = (max(self.gdata.all_keys) -
                              min(self.gdata.all_keys)) / nKeys

        # Setup the colormapper to get the right colors
        self.cmap = None

        max_value = prefs.get('normalization')
        if max_value:
            self.cmap = cm.YlGnBu
        else:
            max_value = 100
            self.cmap = cm.RdYlGn

        self.norms = Normalize(0, max_value)
        mapper = cm.ScalarMappable(cmap=self.cmap, norm=self.norms)

        def get_alpha(*args, **kw):
            return 1.0

        mapper.get_alpha = get_alpha
        self.mapper = mapper
Example #2
0
  def __init__( self, data, ax, prefs, *args, **kw ):

    PlotBase.__init__( self, data, ax, prefs, *args, **kw )
    if isinstance( data, dict ):
      self.gdata = GraphData( data )
    elif isinstance( data, type ) and data.__class__ == GraphData:
      self.gdata = data
    if self.prefs.has_key( 'span' ):
      self.width = self.prefs['span']
    else:
      self.width = 1.0
      if self.gdata.key_type == "time":
        nKeys = self.gdata.getNumberOfKeys()
        self.width = ( max( self.gdata.all_keys ) - min( self.gdata.all_keys ) ) / nKeys

    # Setup the colormapper to get the right colors
    self.cmap = None

    max_value = prefs.get( 'normalization' )
    if max_value:
      self.cmap = cm.YlGnBu #pylint: disable=no-member
    else:
      max_value = 100
      self.cmap = cm.RdYlGn #pylint: disable=no-member

    self.norms = Normalize( 0, max_value )
    mapper = cm.ScalarMappable( cmap = self.cmap, norm = self.norms )
    def get_alpha( *args, **kw ):
      return 1.0
    mapper.get_alpha = get_alpha
    self.mapper = mapper
Example #3
0
  def __init__( self, data, ax, prefs, *args, **kw ):

    PlotBase.__init__( self, data, ax, prefs, *args, **kw )
    if type( data ) == types.DictType:
      self.gdata = GraphData( data )
    elif type( data ) == types.InstanceType and data.__class__ == GraphData:
      self.gdata = data
    if self.prefs.has_key( 'span' ):
      self.width = self.prefs['span']
    else:
      self.width = 1.0
      if self.gdata.key_type == "time":
        nKeys = self.gdata.getNumberOfKeys()
        self.width = ( max( self.gdata.all_keys ) - min( self.gdata.all_keys ) ) / nKeys

    # Setup the colormapper to get the right colors
    self.cmap = LinearSegmentedColormap( 'quality_colormap', cdict, 256 )
    #self.cmap = cm.RdYlGn
    self.norms = normalize( 0, 100 )
    mapper = cm.ScalarMappable( cmap = self.cmap, norm = self.norms )
    mapper = cm.ScalarMappable( cmap = cm.RdYlGn, norm = self.norms )
    def get_alpha( *args, **kw ):
      return 1.0
    mapper.get_alpha = get_alpha
    self.mapper = mapper
Example #4
0
    def __init__(self, data, ax, prefs, *args, **kw):

        PlotBase.__init__(self, data, ax, prefs, *args, **kw)
        if type(data) == types.DictType:
            self.gdata = GraphData(data)
        elif type(data) == types.InstanceType and data.__class__ == GraphData:
            self.gdata = data
        if self.prefs.has_key('span'):
            self.width = self.prefs['span']
        else:
            self.width = 1.0
            if self.gdata.key_type == "time":
                nKeys = self.gdata.getNumberOfKeys()
                self.width = (max(self.gdata.all_keys) -
                              min(self.gdata.all_keys)) / nKeys

        # Setup the colormapper to get the right colors
        self.cmap = LinearSegmentedColormap('quality_colormap', cdict, 256)
        #self.cmap = cm.RdYlGn
        self.norms = normalize(0, 100)
        mapper = cm.ScalarMappable(cmap=self.cmap, norm=self.norms)
        mapper = cm.ScalarMappable(cmap=cm.RdYlGn, norm=self.norms)

        def get_alpha(*args, **kw):
            return 1.0

        mapper.get_alpha = get_alpha
        self.mapper = mapper
Example #5
0
    def __init__(self, data, ax, prefs, *args, **kw):

        PlotBase.__init__(self, data, ax, prefs, *args, **kw)
        if type(data) == types.DictType:
            self.gdata = GraphData(data)
        elif type(data) == types.InstanceType and data.__class__ == GraphData:
            self.gdata = data
        if self.prefs.has_key("span"):
            self.width = self.prefs["span"]
        else:
            self.width = 1.0
            if self.gdata.key_type == "time":
                nKeys = self.gdata.getNumberOfKeys()
                self.width = (max(self.gdata.all_keys) - min(self.gdata.all_keys)) / nKeys

        # Setup the colormapper to get the right colors
        self.cmap = None

        max_value = prefs.get("normalization")
        if max_value:
            self.cmap = cm.YlGnBu
        else:
            max_value = 100
            self.cmap = cm.RdYlGn

        self.norms = Normalize(0, max_value)
        mapper = cm.ScalarMappable(cmap=self.cmap, norm=self.norms)

        def get_alpha(*args, **kw):
            return 1.0

        mapper.get_alpha = get_alpha
        self.mapper = mapper
Example #6
0
  def __init__(self,data,ax,prefs,*args,**kw):

    PlotBase.__init__(self,data,ax,prefs,*args,**kw)
    if self.prefs.has_key('span'):
      self.width = self.prefs['span']
    else:
      self.width = 1.0
      if self.gdata.key_type == "time":
        # Try to guess the time bin span
        nKeys = self.gdata.getNumberOfKeys()
        self.width = (max(self.gdata.all_keys)-min(self.gdata.all_keys))/(nKeys-1)
Example #7
0
  def __init__(self, data, ax, prefs, *args, **kw):

    PlotBase.__init__(self, data, ax, prefs, *args, **kw)
    if 'span' in self.prefs:
      self.width = self.prefs['span']
    else:
      self.width = 1.0
      if self.gdata.key_type == "time":
        # Try to guess the time bin span
        nKeys = self.gdata.getNumberOfKeys()
        self.width = (max(self.gdata.all_keys) - min(self.gdata.all_keys)) / (nKeys - 1)
Example #8
0
    def __init__(self, data, ax, prefs, *args, **kw):

        PlotBase.__init__(self, data, ax, prefs, *args, **kw)
        if isinstance(data, dict):
            self.gdata = GraphData(data)
        elif isinstance(data, type) and data.__class__ == GraphData:
            self.gdata = data
        if "span" in self.prefs:
            self.width = self.prefs["span"]
        else:
            self.width = 1.0
            if self.gdata.key_type == "time":
                nKeys = self.gdata.getNumberOfKeys()
                self.width = (max(self.gdata.all_keys) -
                              min(self.gdata.all_keys)) / nKeys

        # redefine the look of the scale if requested
        if isinstance(self.prefs["scale_data"], dict):
            self.cbBoundaries = list()
            self.cbValues = list()

            # ColorbarBase needs sorted data
            for boundary in sorted(self.prefs["scale_data"]):
                self.cbBoundaries.append(boundary)
                self.cbValues.append(self.prefs["scale_data"][boundary])
        else:
            self.cbBoundaries = None  # set default values
            self.cbValues = None

        if isinstance(self.prefs["scale_ticks"], list):
            self.cbTicks = self.prefs["scale_ticks"]
        else:
            self.cbTicks = None  # set default value

        # Setup the colormapper to get the right colors
        self.cmap = None

        max_value = prefs.get("normalization")
        if max_value:
            self.cmap = cm.YlGnBu  # pylint: disable=no-member
        else:
            max_value = 100
            self.cmap = cm.RdYlGn  # pylint: disable=no-member

        self.norms = Normalize(0, max_value)
        mapper = cm.ScalarMappable(cmap=self.cmap, norm=self.norms)

        def get_alpha(*args, **kw):
            return 1.0

        mapper.get_alpha = get_alpha
        self.mapper = mapper
Example #9
0
  def __init__( self, data, ax, prefs, *args, **kw ):

    PlotBase.__init__( self, data, ax, prefs, *args, **kw )
    if isinstance( data, dict ):
      self.gdata = GraphData( data )
    elif isinstance( data, type ) and data.__class__ == GraphData:
      self.gdata = data
    if self.prefs.has_key( 'span' ):
      self.width = self.prefs['span']
    else:
      self.width = 1.0
      if self.gdata.key_type == "time":
        nKeys = self.gdata.getNumberOfKeys()
        self.width = ( max( self.gdata.all_keys ) - min( self.gdata.all_keys ) ) / nKeys

    # redefine the look of the scale if requested
    if isinstance(self.prefs['scale_data'], dict):
      self.cbBoundaries = list()
      self.cbValues = list()

      # ColorbarBase needs sorted data
      for boundary in sorted(self.prefs['scale_data'].keys()):
        self.cbBoundaries.append(boundary)
        self.cbValues.append(self.prefs['scale_data'][boundary])
    else:
      self.cbBoundaries = None # set default values
      self.cbValues = None

    if isinstance(self.prefs['scale_ticks'], list):
      self.cbTicks = self.prefs['scale_ticks']
    else:
      self.cbTicks = None # set default value

    # Setup the colormapper to get the right colors
    self.cmap = None

    max_value = prefs.get( 'normalization' )
    if max_value:
      self.cmap = cm.YlGnBu #pylint: disable=no-member
    else:
      max_value = 100
      self.cmap = cm.RdYlGn #pylint: disable=no-member

    self.norms = Normalize( 0, max_value )
    mapper = cm.ScalarMappable( cmap = self.cmap, norm = self.norms )
    def get_alpha( *args, **kw ):
      return 1.0
    mapper.get_alpha = get_alpha
    self.mapper = mapper
Example #10
0
  def draw( self ):

    self.ylabel = ''
    self.prefs['square_axis'] = True
    PlotBase.draw( self )
    def my_display( x ):
      if x > 100 * self.min_amount:
        return '%.1f' % x + '%'
      else:
        return ""

    nLabels = self.pdata.getNumberOfLabels()
    explode = [0.] * nLabels
    if nLabels > 0:
      explode[0] = 0.1
    self.wedges, text_labels, percent = self.pie( explode = explode, autopct = my_display )
Example #11
0
    def draw(self):

        self.ylabel = ""
        self.prefs["square_axis"] = True
        PlotBase.draw(self)

        def my_display(x):
            if x > 100 * self.min_amount:
                return "%.1f" % x + "%"
            else:
                return ""

        nLabels = self.pdata.getNumberOfLabels()
        explode = [0.0] * nLabels
        if nLabels > 0:
            explode[0] = 0.1
        self.wedges, text_labels, percent = self.pie(explode=explode, autopct=my_display)
Example #12
0
    def draw(self):

        PlotBase.draw(self)
        self.x_formatter_cb(self.ax)

        if self.gdata.isEmpty():
            return None

        # Evaluate the bar width
        width = float(self.width)
        offset = 0.0
        if self.gdata.key_type == "time":
            width = width / 86400.0

        start_plot = 0
        end_plot = 0
        if "starttime" in self.prefs and "endtime" in self.prefs:
            start_plot = date2num(
                datetime.datetime.fromtimestamp(
                    to_timestamp(self.prefs["starttime"])))
            end_plot = date2num(
                datetime.datetime.fromtimestamp(
                    to_timestamp(self.prefs["endtime"])))

        labels = self.gdata.getLabels()
        nKeys = self.gdata.getNumberOfKeys()
        tmp_b = []
        tmp_x = []
        tmp_y = []

        self.bars = []
        labels = self.gdata.getLabels()
        nLabel = 0
        labelNames = []
        colors = []
        xmin = None
        xmax = None
        for label, _num in labels:
            labelNames.append(label)
            for key, value, _error in self.gdata.getPlotNumData(label):

                if xmin is None or xmin > (key + offset):
                    xmin = key + offset
                if xmax is None or xmax < (key + offset):
                    xmax = key + offset

                if value is not None:
                    colors.append(self.getQualityColor(value))
                    tmp_x.append(key + offset)
                    tmp_y.append(1.0)
                    tmp_b.append(float(nLabel))

            nLabel += 1

        self.bars += self.ax.bar(tmp_x,
                                 tmp_y,
                                 bottom=tmp_b,
                                 width=width,
                                 color=colors)

        dpi = self.prefs.get("dpi", 100)
        setp(self.bars, linewidth=pixelToPoint(0.5, dpi), edgecolor="#AAAAAA")

        # pivots = keys
        # for idx in range(len(pivots)):
        #    self.coords[ pivots[idx] ] = self.bars[idx]

        ymax = float(nLabel)
        self.ax.set_xlim(xmin=0.0, xmax=xmax + width + offset)
        self.ax.set_ylim(ymin=0.0, ymax=ymax)
        if self.gdata.key_type == "time":
            if start_plot and end_plot:
                self.ax.set_xlim(xmin=start_plot, xmax=end_plot)
            else:
                self.ax.set_xlim(xmin=min(tmp_x), xmax=max(tmp_x))
        self.ax.set_yticks([i + 0.5 for i in range(nLabel)])
        self.ax.set_yticklabels(labelNames)
        setp(self.ax.get_xticklines(), markersize=0.0)
        setp(self.ax.get_yticklines(), markersize=0.0)

        cax, kw = make_axes(self.ax, orientation="vertical", fraction=0.07)
        cb = ColorbarBase(cax,
                          cmap=self.cmap,
                          norm=self.norms,
                          boundaries=self.cbBoundaries,
                          values=self.cbValues,
                          ticks=self.cbTicks)
        cb.draw_all()
Example #13
0
    def draw(self):

        PlotBase.draw(self)
        self.x_formatter_cb(self.ax)

        if self.gdata.isEmpty():
            return None

        tmp_x = []
        tmp_y = []

        # Evaluate the bar width
        width = float(self.width)
        if self.gdata.key_type == 'time':
            #width = (1 - self.bar_graph_space) * width / 86400.0
            width = width / 86400.0
            offset = 0
        elif self.gdata.key_type == 'string':
            self.bar_graph_space = 0.1
            width = (1 - self.bar_graph_space) * width
            offset = self.bar_graph_space / 2.0
        else:
            offset = 0

        start_plot = 0
        end_plot = 0
        if "starttime" in self.prefs and "endtime" in self.prefs:
            start_plot = date2num(
                datetime.datetime.fromtimestamp(
                    to_timestamp(self.prefs['starttime'])))
            end_plot = date2num(
                datetime.datetime.fromtimestamp(
                    to_timestamp(self.prefs['endtime'])))

        nKeys = self.gdata.getNumberOfKeys()
        tmp_b = []
        if self.prefs.has_key('log_yaxis'):
            tmp_b = [0.001] * nKeys
            ymin = 0.001
        else:
            tmp_b = [0.] * nKeys
            ymin = 0.

        self.polygons = []
        self.lines = []
        labels = self.gdata.getLabels()
        labels.reverse()

        # If it is a simple plot, no labels are used
        # Evaluate the most appropriate color in this case
        if self.gdata.isSimplePlot():
            labels = [('SimplePlot', 0.)]
            color = self.prefs.get('plot_color', 'Default')
            if color.find('#') != -1:
                self.palette.setColor('SimplePlot', color)
            else:
                labels = [(color, 0.)]

        seq_b = [(self.gdata.max_num_key + width, 0.0),
                 (self.gdata.min_num_key, 0.0)]
        zorder = 0.0
        dpi = self.prefs.get('dpi', 100)
        for label, num in labels:
            color = self.palette.getColor(label)
            ind = 0
            tmp_x = []
            tmp_y = []
            tmp_t = []
            plot_data = self.gdata.getPlotNumData(label)
            for key, value, error in plot_data:
                if value is None:
                    value = 0.

                tmp_x.append(offset + key)
                #tmp_y.append( ymin )
                tmp_y.append(0.001)
                tmp_x.append(offset + key)
                tmp_y.append(float(value) + tmp_b[ind])
                tmp_x.append(offset + key + width)
                tmp_y.append(float(value) + tmp_b[ind])
                tmp_x.append(offset + key + width)
                #tmp_y.append( ymin )
                tmp_y.append(0.001)
                tmp_t.append(float(value) + tmp_b[ind])
                ind += 1
            seq_t = zip(tmp_x, tmp_y)
            seq = seq_t + seq_b
            poly = Polygon(seq,
                           facecolor=color,
                           fill=True,
                           linewidth=pixelToPoint(0.2, dpi),
                           zorder=zorder)
            self.ax.add_patch(poly)
            self.polygons.append(poly)
            tmp_b = list(tmp_t)
            zorder -= 0.1

        tight_bars_flag = self.prefs.get('tight_bars', False)
        if tight_bars_flag:
            setp(self.polygons, linewidth=0.)

        #pivots = keys
        #for idx in range(len(pivots)):
        #    self.coords[ pivots[idx] ] = self.bars[idx]

        ymax = max(tmp_b)
        ymax *= 1.1

        if self.prefs.has_key('log_yaxis'):
            ymin = 0.001
        else:
            ymin = min(tmp_b, 0.)
            ymin *= 1.1

        xmax = max(tmp_x)
        if self.log_xaxis:
            xmin = 0.001
        else:
            xmin = 0

        ymin = self.prefs.get('ymin', ymin)
        ymax = self.prefs.get('ymax', ymax)
        xmin = self.prefs.get('xmin', xmin)
        xmax = self.prefs.get('xmax', xmax)

        self.ax.set_xlim(xmin=xmin, xmax=xmax + offset)
        self.ax.set_ylim(ymin=ymin, ymax=ymax)
        if self.gdata.key_type == 'time':
            if start_plot and end_plot:
                self.ax.set_xlim(xmin=start_plot, xmax=end_plot)
            else:
                self.ax.set_xlim(xmin=min(tmp_x), xmax=max(tmp_x))
Example #14
0
  def draw( self ):

    PlotBase.draw(self)
    self.x_formatter_cb(self.ax)

    if self.gdata.isEmpty():
      return None

    tmp_x = []; tmp_y = []

    # Evaluate the bar width
    width = float(self.width)
    if self.gdata.key_type == 'time':
      #width = (1 - self.bar_graph_space) * width / 86400.0
      width = width / 86400.0
      offset = 0
    elif self.gdata.key_type == 'string':
      self.bar_graph_space = 0.1
      width = (1 - self.bar_graph_space) * width
      offset = self.bar_graph_space / 2.0
    else:
      offset = 0

    start_plot = 0
    end_plot = 0
    if "starttime" in self.prefs and "endtime" in self.prefs:
      start_plot = date2num( datetime.datetime.fromtimestamp(to_timestamp(self.prefs['starttime'])))
      end_plot = date2num( datetime.datetime.fromtimestamp(to_timestamp(self.prefs['endtime'])))

    nKeys = self.gdata.getNumberOfKeys()
    tmp_b = []
    if self.prefs.has_key('log_yaxis'):
      tmp_b = [0.001]*nKeys
      ymin = 0.001
    else:
      tmp_b = [0.]*nKeys
      ymin = 0.

    self.polygons = []
    self.lines = []
    labels = self.gdata.getLabels()
    labels.reverse()

    # If it is a simple plot, no labels are used
    # Evaluate the most appropriate color in this case
    if self.gdata.isSimplePlot():
      labels = [('SimplePlot',0.)]
      color = self.prefs.get('plot_color','Default')
      if color.find('#') != -1:
        self.palette.setColor('SimplePlot',color)
      else:
        labels = [(color,0.)]

    seq_b = [(self.gdata.max_num_key+width,0.0),(self.gdata.min_num_key,0.0)]
    zorder = 0.0
    dpi = self.prefs.get('dpi',100)
    for label,num in labels:
      color = self.palette.getColor(label)
      ind = 0
      tmp_x = []
      tmp_y = []
      tmp_t = []
      plot_data = self.gdata.getPlotNumData(label)
      for key, value, error in plot_data:
        if value is None:
          value = 0.

        tmp_x.append( offset+key )
        #tmp_y.append( ymin )
        tmp_y.append( 0.001 )
        tmp_x.append( offset+key )
        tmp_y.append( float(value)+tmp_b[ind] )
        tmp_x.append( offset+key+width )
        tmp_y.append( float(value)+tmp_b[ind] )
        tmp_x.append( offset+key+width )
        #tmp_y.append( ymin )
        tmp_y.append( 0.001 )
        tmp_t.append(float(value)+tmp_b[ind])
        ind += 1
      seq_t = zip(tmp_x,tmp_y)
      seq = seq_t+seq_b
      poly = Polygon( seq, facecolor=color, fill=True,
                      linewidth=pixelToPoint(0.2,dpi),
                      zorder=zorder)
      self.ax.add_patch( poly )
      self.polygons.append( poly )
      tmp_b = list(tmp_t)
      zorder -= 0.1

    tight_bars_flag = self.prefs.get('tight_bars',False)
    if tight_bars_flag:
      setp( self.polygons, linewidth=0. )

    #pivots = keys
    #for idx in range(len(pivots)):
    #    self.coords[ pivots[idx] ] = self.bars[idx]

    ymax = max(tmp_b)
    ymax *= 1.1

    if self.prefs.has_key('log_yaxis'):
      ymin = 0.001
    else:
      ymin = min( tmp_b, 0. )
      ymin *= 1.1

    xmax=max(tmp_x)
    if self.log_xaxis:
      xmin = 0.001
    else:
      xmin = 0

    ymin = self.prefs.get( 'ymin', ymin )
    ymax = self.prefs.get( 'ymax', ymax )
    xmin = self.prefs.get( 'xmin', xmin )
    xmax = self.prefs.get( 'xmax', xmax )

    self.ax.set_xlim( xmin=xmin, xmax=xmax+offset )
    self.ax.set_ylim( ymin=ymin, ymax=ymax )
    if self.gdata.key_type == 'time':
      if start_plot and end_plot:
        self.ax.set_xlim( xmin=start_plot, xmax=end_plot)
      else:
        self.ax.set_xlim( xmin=min(tmp_x), xmax=max(tmp_x))
Example #15
0
    def __init__(self, data, ax, prefs, *args, **kw):

        PlotBase.__init__(self, data, ax, prefs, *args, **kw)
Example #16
0
    def draw(self):

        PlotBase.draw(self)
        self.x_formatter_cb(self.ax)

        if self.gdata.isEmpty():
            return None

        start_plot = 0
        end_plot = 0
        if "starttime" in self.prefs and "endtime" in self.prefs:
            start_plot = date2num(datetime.datetime.fromtimestamp(to_timestamp(self.prefs["starttime"])))
            end_plot = date2num(datetime.datetime.fromtimestamp(to_timestamp(self.prefs["endtime"])))

        labels = self.gdata.getLabels()
        labels.reverse()

        # If it is a simple plot, no labels are used
        # Evaluate the most appropriate color in this case
        if self.gdata.isSimplePlot():
            labels = [("SimplePlot", 0.0)]
            color = self.prefs.get("plot_color", "Default")
            if color.find("#") != -1:
                self.palette.setColor("SimplePlot", color)
            else:
                labels = [(color, 0.0)]

        tmp_max_y = []
        tmp_min_y = []
        tmp_x = []
        for label, num in labels:
            xdata = []
            ydata = []
            xerror = []
            yerror = []
            color = self.palette.getColor(label)
            plot_data = self.gdata.getPlotNumData(label)
            for key, value, error in plot_data:
                if value is None:
                    continue
                tmp_x.append(key)
                tmp_max_y.append(value + error)
                tmp_min_y.append(value - error)
                xdata.append(key)
                ydata.append(value)
                xerror.append(0.0)
                yerror.append(error)

            linestyle = self.prefs.get("linestyle", "-")
            marker = self.prefs.get("marker", "o")
            markersize = self.prefs.get("markersize", 8.0)
            markeredgewidth = self.prefs.get("markeredgewidth", 1.0)
            if not self.prefs.get("error_bars", False):
                line = Line2D(
                    xdata,
                    ydata,
                    color=color,
                    linewidth=1.0,
                    marker=marker,
                    linestyle=linestyle,
                    markersize=markersize,
                    markeredgewidth=markeredgewidth,
                    markeredgecolor=darkenColor(color),
                )
                self.ax.add_line(line)
            else:
                self.ax.errorbar(
                    xdata,
                    ydata,
                    color=color,
                    linewidth=2.0,
                    marker=marker,
                    linestyle=linestyle,
                    markersize=markersize,
                    markeredgewidth=markeredgewidth,
                    markeredgecolor=darkenColor(color),
                    xerr=xerror,
                    yerr=yerror,
                    ecolor=color,
                )

        ymax = max(tmp_max_y)
        ymax *= 1.1
        ymin = min(tmp_min_y, 0.0)
        ymin *= 1.1
        if "log_yaxis" in self.prefs:
            ymin = 0.001

        xmax = max(tmp_x) * 1.1
        if self.log_xaxis:
            xmin = 0.001
        else:
            xmin = 0

        ymin = self.prefs.get("ymin", ymin)
        ymax = self.prefs.get("ymax", ymax)
        xmin = self.prefs.get("xmin", xmin)
        xmax = self.prefs.get("xmax", xmax)

        self.ax.set_xlim(xmin=xmin, xmax=xmax)
        self.ax.set_ylim(ymin=ymin, ymax=ymax)
        if self.gdata.key_type == "time":
            if start_plot and end_plot:
                self.ax.set_xlim(xmin=start_plot, xmax=end_plot)
            else:
                self.ax.set_xlim(xmin=min(tmp_x), xmax=max(tmp_x))
Example #17
0
  def draw( self ):

    PlotBase.draw( self )
    self.x_formatter_cb( self.ax )

    if self.gdata.isEmpty():
      return None

    tmp_x = []; tmp_y = []

    # Evaluate the bar width
    width = float( self.width )
    offset = 0.
    if self.gdata.key_type == 'time':
      width = width / 86400.0

    start_plot = 0
    end_plot = 0
    if "starttime" in self.prefs and "endtime" in self.prefs:
      start_plot = date2num( datetime.datetime.fromtimestamp( to_timestamp( self.prefs['starttime'] ) ) )
      end_plot = date2num( datetime.datetime.fromtimestamp( to_timestamp( self.prefs['endtime'] ) ) )

    labels = self.gdata.getLabels()
    nKeys = self.gdata.getNumberOfKeys()
    tmp_b = []
    tmp_x = []
    tmp_y = []

    self.bars = []
    labels = self.gdata.getLabels()
    nLabel = 0
    labelNames = []
    colors = []
    xmin = None
    xmax = None
    for label, num in labels:
      labelNames.append( label )
      for key, value in self.gdata.getPlotNumData( label ):

        if xmin is None or xmin > ( key + offset ):
          xmin = key + offset
        if xmax is None or xmax < ( key + offset ):
          xmax = key + offset

        if value is not None:
          colors.append( self.getQualityColor( value ) )
          tmp_x.append( key + offset )
          tmp_y.append( 1. )
          tmp_b.append( float( nLabel ) )

      nLabel += 1

    self.bars += self.ax.bar( tmp_x, tmp_y, bottom = tmp_b, width = width, color = colors )

    dpi = self.prefs.get( 'dpi', 100 )
    setp( self.bars, linewidth = pixelToPoint( 0.5, dpi ), edgecolor = '#AAAAAA' )

    #pivots = keys
    #for idx in range(len(pivots)):
    #    self.coords[ pivots[idx] ] = self.bars[idx]

    ymax = float( nLabel )
    self.ax.set_xlim( xmin = 0., xmax = xmax + width + offset )
    self.ax.set_ylim( ymin = 0., ymax = ymax )
    if self.gdata.key_type == 'time':
      if start_plot and end_plot:
        self.ax.set_xlim( xmin = start_plot, xmax = end_plot )
      else:
        self.ax.set_xlim( xmin = min( tmp_x ), xmax = max( tmp_x ) )
    self.ax.set_yticks( [ i + 0.5 for i in range( nLabel ) ] )
    self.ax.set_yticklabels( labelNames )
    setp( self.ax.get_xticklines(), markersize = 0. )
    setp( self.ax.get_yticklines(), markersize = 0. )

    cax, kw = make_axes( self.ax, orientation = 'vertical', fraction = 0.07 )
    cb = ColorbarBase( cax, cmap = cm.RdYlGn, norm = self.norms )
    cb.draw_all()
Example #18
0
  def __init__(self,data,ax,prefs,*args,**kw):

    PlotBase.__init__(self,data,ax,prefs,*args,**kw)
Example #19
0
 def draw( self ):
 
   PlotBase.draw(self)
   self.x_formatter_cb(self.ax)
 
   if self.gdata.isEmpty():
     return None
       
   tmp_x = []; tmp_y = []
       
   labels = self.gdata.getLabels()  
   nKeys = self.gdata.getNumberOfKeys()
   tmp_b = []
   for n in range(nKeys):
     if self.prefs.has_key('log_yaxis'):
       tmp_b.append(0.001)
       ymin = 0.001
     else:
       tmp_b.append(0.)  
       ymin = 0.
       
   start_plot = 0
   end_plot = 0    
   if "starttime" in self.prefs and "endtime" in self.prefs:
     start_plot = date2num( datetime.datetime.fromtimestamp(to_timestamp(self.prefs['starttime'])))    
     end_plot = date2num( datetime.datetime.fromtimestamp(to_timestamp(self.prefs['endtime'])))                         
     
   self.polygons = []
   seq_b = [(self.gdata.max_num_key,0.0),(self.gdata.min_num_key,0.0)]    
   zorder = 0.0      
   labels = self.gdata.getLabels()
   labels.reverse()
   
   # If it is a simple plot, no labels are used
   # Evaluate the most appropriate color in this case
   if self.gdata.isSimplePlot():
     labels = [('SimplePlot',0.)]
     color = self.prefs.get('plot_color','Default')
     if color.find('#') != -1:
       self.palette.setColor('SimplePlot',color)
     else:
       labels = [(color,0.)]
     
   for label,num in labels:  
   
     color = self.palette.getColor(label)
     ind = 0
     tmp_x = []
     tmp_y = []
     plot_data = self.gdata.getPlotNumData(label)
     for key, value in plot_data:
       if value is None:
         value = 0.
       tmp_x.append( key )
       tmp_y.append( float(value)+tmp_b[ind] )   
       ind += 1       
     seq_t = zip(tmp_x,tmp_y)     
     seq = seq_t+seq_b       
     poly = Polygon( seq, facecolor=color, fill=True, linewidth=.2, zorder=zorder)
     self.ax.add_patch( poly )
     self.polygons.append( poly )        
     tmp_b = list(tmp_y)  
     zorder -= 0.1
                   
   ymax = max(tmp_b); ymax *= 1.1
   if self.log_xaxis:  
     xmin = 0.001
   else: 
     xmin = 0
   self.ax.set_xlim( xmin=xmin, xmax=max(tmp_x) )
   self.ax.set_ylim( ymin=ymin, ymax=ymax )
   if self.gdata.key_type == 'time':
     if start_plot and end_plot:
       self.ax.set_xlim( xmin=start_plot, xmax=end_plot)   
     else:      
       self.ax.set_xlim( xmin=min(tmp_x), xmax=max(tmp_x))     
Example #20
0
 def draw( self ):
 
   PlotBase.draw(self)
   self.x_formatter_cb(self.ax)
 
   if self.gdata.isEmpty():
     return None
       
   start_plot = 0
   end_plot = 0    
   if "starttime" in self.prefs and "endtime" in self.prefs:
     start_plot = date2num( datetime.datetime.fromtimestamp(to_timestamp(self.prefs['starttime'])))    
     end_plot = date2num( datetime.datetime.fromtimestamp(to_timestamp(self.prefs['endtime'])))                         
     
   labels = self.gdata.getLabels()
   labels.reverse()
   
   # If it is a simple plot, no labels are used
   # Evaluate the most appropriate color in this case
   if self.gdata.isSimplePlot():
     labels = [('SimplePlot',0.)]
     color = self.prefs.get('plot_color','Default')
     if color.find('#') != -1:
       self.palette.setColor('SimplePlot',color)
     else:
       labels = [(color,0.)]
     
   tmp_max_y = []
   tmp_min_y = []
   tmp_x = []
   for label,num in labels:  
     xdata = []
     ydata = []
     xerror = []
     yerror = []
     color = self.palette.getColor(label)      
     plot_data = self.gdata.getPlotNumData(label)
     for key, value, error in plot_data:
       if value is None:
         continue
       tmp_x.append( key )
       tmp_max_y.append( value + error )
       tmp_min_y.append( value - error )   
       xdata.append( key )
       ydata.append( value )
       xerror.append( 0. )
       yerror.append( error )
       
     linestyle = self.prefs.get( 'linestyle', '-' )  
     marker = self.prefs.get( 'marker', 'o' )  
     markersize = self.prefs.get( 'markersize', 8. )  
     markeredgewidth = self.prefs.get( 'markeredgewidth', 1. )  
     if not self.prefs.get( 'error_bars', False ):
       line = Line2D( xdata, ydata, color=color, linewidth=1., marker=marker, linestyle=linestyle,  
                      markersize=markersize, markeredgewidth=markeredgewidth, 
                      markeredgecolor = darkenColor( color ) )
       self.ax.add_line( line )
     else:
       self.ax.errorbar( xdata, ydata, color=color, linewidth=2., marker=marker, linestyle=linestyle,  
                         markersize=markersize, markeredgewidth=markeredgewidth, 
                         markeredgecolor = darkenColor( color ), xerr = xerror, yerr = yerror, 
                         ecolor=color )  
     
                   
   ymax = max( tmp_max_y )
   ymax *= 1.1
   ymin = min( tmp_min_y, 0. )
   ymin *= 1.1
   if self.prefs.has_key('log_yaxis'):
     ymin = 0.001
   
   xmax=max(tmp_x)*1.1
   if self.log_xaxis:  
     xmin = 0.001
   else: 
     xmin = 0
     
   ymin = self.prefs.get( 'ymin', ymin )  
   ymax = self.prefs.get( 'ymax', ymax )
   xmin = self.prefs.get( 'xmin', xmin )  
   xmax = self.prefs.get( 'xmax', xmax )   
     
   self.ax.set_xlim( xmin=xmin, xmax=xmax  )
   self.ax.set_ylim( ymin=ymin, ymax=ymax )
   if self.gdata.key_type == 'time':
     if start_plot and end_plot:
       self.ax.set_xlim( xmin=start_plot, xmax=end_plot)   
     else:      
       self.ax.set_xlim( xmin=min(tmp_x), xmax=max(tmp_x))     
Example #21
0
    def draw(self):

        PlotBase.draw(self)
        self.x_formatter_cb(self.ax)

        if self.gdata.isEmpty():
            return None

        tmp_x = []
        tmp_y = []

        labels = self.gdata.getLabels()
        nKeys = self.gdata.getNumberOfKeys()
        tmp_b = []
        for n in range(nKeys):
            if 'log_yaxis' in self.prefs:
                tmp_b.append(0.001)
            else:
                tmp_b.append(0.)

        start_plot = 0
        end_plot = 0
        if "starttime" in self.prefs and "endtime" in self.prefs:
            start_plot = date2num(
                datetime.datetime.fromtimestamp(
                    to_timestamp(self.prefs['starttime'])))
            end_plot = date2num(
                datetime.datetime.fromtimestamp(
                    to_timestamp(self.prefs['endtime'])))

        self.polygons = []
        seq_b = [(self.gdata.max_num_key, 0.0), (self.gdata.min_num_key, 0.0)]
        zorder = 0.0
        labels = self.gdata.getLabels()
        labels.reverse()

        # If it is a simple plot, no labels are used
        # Evaluate the most appropriate color in this case
        if self.gdata.isSimplePlot():
            labels = [('SimplePlot', 0.)]
            color = self.prefs.get('plot_color', 'Default')
            if color.find('#') != -1:
                self.palette.setColor('SimplePlot', color)
            else:
                labels = [(color, 0.)]

        for label, num in labels:

            color = self.palette.getColor(label)
            ind = 0
            tmp_x = []
            tmp_y = []
            plot_data = self.gdata.getPlotNumData(label)
            for key, value, error in plot_data:
                if value is None:
                    value = 0.
                tmp_x.append(key)
                tmp_y.append(float(value) + tmp_b[ind])
                ind += 1
            seq_t = zip(tmp_x, tmp_y)
            seq = seq_t + seq_b
            poly = Polygon(seq,
                           facecolor=color,
                           fill=True,
                           linewidth=.2,
                           zorder=zorder)
            self.ax.add_patch(poly)
            self.polygons.append(poly)
            tmp_b = list(tmp_y)
            zorder -= 0.1

        ymax = max(tmp_b)
        ymax *= 1.1
        ymin = min(tmp_b, 0.)
        ymin *= 1.1
        if 'log_yaxis' in self.prefs:
            ymin = 0.001
        xmax = max(tmp_x)
        if self.log_xaxis:
            xmin = 0.001
        else:
            xmin = 0

        ymin = self.prefs.get('ymin', ymin)
        ymax = self.prefs.get('ymax', ymax)
        xmin = self.prefs.get('xmin', xmin)
        xmax = self.prefs.get('xmax', xmax)

        self.ax.set_xlim(xmin=xmin, xmax=xmax)
        self.ax.set_ylim(ymin=ymin, ymax=ymax)
        if self.gdata.key_type == 'time':
            if start_plot and end_plot:
                self.ax.set_xlim(xmin=start_plot, xmax=end_plot)
            else:
                self.ax.set_xlim(xmin=min(tmp_x), xmax=max(tmp_x))
Example #22
0
    def draw(self):

        PlotBase.draw(self)
        self.x_formatter_cb(self.ax)

        if self.gdata.isEmpty():
            return None

        start_plot = 0
        end_plot = 0
        if "starttime" in self.prefs and "endtime" in self.prefs:
            start_plot = date2num(
                datetime.datetime.fromtimestamp(
                    to_timestamp(self.prefs['starttime'])))
            end_plot = date2num(
                datetime.datetime.fromtimestamp(
                    to_timestamp(self.prefs['endtime'])))

        labels = self.gdata.getLabels()
        labels.reverse()

        # If it is a simple plot, no labels are used
        # Evaluate the most appropriate color in this case
        if self.gdata.isSimplePlot():
            labels = [('SimplePlot', 0.)]
            color = self.prefs.get('plot_color', 'Default')
            if color.find('#') != -1:
                self.palette.setColor('SimplePlot', color)
            else:
                labels = [(color, 0.)]

        tmp_max_y = []
        tmp_min_y = []
        tmp_x = []
        for label, num in labels:
            xdata = []
            ydata = []
            xerror = []
            yerror = []
            color = self.palette.getColor(label)
            plot_data = self.gdata.getPlotNumData(label)
            for key, value, error in plot_data:
                if value is None:
                    continue
                tmp_x.append(key)
                tmp_max_y.append(value + error)
                tmp_min_y.append(value - error)
                xdata.append(key)
                ydata.append(value)
                xerror.append(0.)
                yerror.append(error)

            linestyle = self.prefs.get('linestyle', '-')
            marker = self.prefs.get('marker', 'o')
            markersize = self.prefs.get('markersize', 8.)
            markeredgewidth = self.prefs.get('markeredgewidth', 1.)
            if not self.prefs.get('error_bars', False):
                line = Line2D(xdata,
                              ydata,
                              color=color,
                              linewidth=1.,
                              marker=marker,
                              linestyle=linestyle,
                              markersize=markersize,
                              markeredgewidth=markeredgewidth,
                              markeredgecolor=darkenColor(color))
                self.ax.add_line(line)
            else:
                self.ax.errorbar(xdata,
                                 ydata,
                                 color=color,
                                 linewidth=2.,
                                 marker=marker,
                                 linestyle=linestyle,
                                 markersize=markersize,
                                 markeredgewidth=markeredgewidth,
                                 markeredgecolor=darkenColor(color),
                                 xerr=xerror,
                                 yerr=yerror,
                                 ecolor=color)

        ymax = max(tmp_max_y)
        ymax *= 1.1
        ymin = min(tmp_min_y, 0.)
        ymin *= 1.1
        if self.prefs.has_key('log_yaxis'):
            ymin = 0.001

        xmax = max(tmp_x) * 1.1
        if self.log_xaxis:
            xmin = 0.001
        else:
            xmin = 0

        ymin = self.prefs.get('ymin', ymin)
        ymax = self.prefs.get('ymax', ymax)
        xmin = self.prefs.get('xmin', xmin)
        xmax = self.prefs.get('xmax', xmax)

        self.ax.set_xlim(xmin=xmin, xmax=xmax)
        self.ax.set_ylim(ymin=ymin, ymax=ymax)
        if self.gdata.key_type == 'time':
            if start_plot and end_plot:
                self.ax.set_xlim(xmin=start_plot, xmax=end_plot)
            else:
                self.ax.set_xlim(xmin=min(tmp_x), xmax=max(tmp_x))