示例#1
0
def get_key_type(keys):
    """ A utility function to guess the type of the plot keys
  """

    min_time_stamp = 1000000000
    max_time_stamp = 1900000000
    time_type = True
    num_type = True
    string_type = True
    key_type = 'unknown'
    for key in keys:
        if time_type:
            try:
                time_data = to_timestamp(key)
                if time_data < min_time_stamp or time_data > max_time_stamp:
                    time_type = False
            except ValueError:
                time_type = False
        if num_type:
            try:
                num_data = float(key)
            except:
                num_type = False
        if type(key) not in types.StringTypes:
            string_type = False

    # Take the most restrictive type
    if string_type:
        key_type = "string"
    if num_type:
        key_type = "numeric"
    if time_type:
        key_type = "time"

    return key_type
示例#2
0
def get_key_type( keys ):
  """ A utility function to guess the type of the plot keys
  """

  min_time_stamp = 1000000000
  max_time_stamp = 1900000000
  time_type = True
  num_type = True
  string_type = True
  key_type = 'unknown'
  for key in keys:
    if time_type:
      try:
        time_data = to_timestamp( key )
        if time_data < min_time_stamp or time_data > max_time_stamp:
          time_type = False
      except ValueError:
        time_type = False
    if num_type:
      try:
        num_data = float( key )
      except:
        num_type = False
    if not isinstance(key, basestring):
      string_type = False

  # Take the most restrictive type
  if string_type:
    key_type = "string"
  if num_type :
    key_type = "numeric"
  if time_type:
    key_type = "time"

  return key_type
示例#3
0
    def parseKey(self, key):
        """
    Parse the name of the pivot; this is the identity function.
    """

        if self.key_type == "time":
            return to_timestamp(key)
        else:
            return key
示例#4
0
  def parseKey( self, key ):
    """
    Parse the name of the pivot; this is the identity function.
    """

    if self.key_type == "time":
      return to_timestamp( key )
    else:
      return key
示例#5
0
文件: GraphData.py 项目: vingar/DIRAC
    def initialize(self):

        if self.key_type == "string":
            self.keys = self.sortKeys('weight')
        else:
            self.keys = self.sortKeys()

        self.values = [self.parsed_data.get(k, 0.0) for k in self.keys]
        self.errors = [self.parsed_errors.get(k, 0.0) for k in self.keys]
        values_to_sum = [
            self.parsed_data.get(k, 0.0) for k in self.keys if k != ''
        ]

        self.real_values = []
        for k in self.keys:
            if self.parsed_data[k] is not None:
                self.real_values.append(self.parsed_data[k])

        self.values_sum = float(sum(self.real_values))

        # Prepare numerical representation of keys for plotting
        self.num_keys = []
        if self.key_type == "string":
            self.string_map = {}
            next = 0
            for key in self.keys:
                self.string_map[key] = next
                self.num_keys.append(next)
                next += 1
        elif self.key_type == "time":
            self.num_keys = [
                date2num(datetime.datetime.fromtimestamp(to_timestamp(key)))
                for key in self.keys
            ]
        elif self.key_type == "numeric":
            self.num_keys = [float(key) for key in self.keys]

        self.min_value = float(min(self.real_values))
        self.max_value = float(max(self.real_values))
        self.min_key = self.keys[0]
        self.max_key = self.keys[-1]
        self.sum_value = float(sum(self.real_values))
        self.last_value = float(self.real_values[-1])

        count = len(filter(lambda a: a != 0, self.real_values))
        if count != 0:
            self.avg_nozeros = self.sum_value / float(count)
        else:
            self.avg_nozeros = 0
示例#6
0
  def initialize( self ):

    if self.key_type == "string":
      self.keys = self.sortKeys( 'weight' )
    else:
      self.keys = self.sortKeys()

    self.values = [ self.parsed_data.get(k, 0.0) for k in self.keys ]
    self.errors = [ self.parsed_errors.get(k, 0.0) for k in self.keys ]
    values_to_sum = [ self.parsed_data.get(k, 0.0) for k in self.keys if k != '' ]

    self.real_values = []
    for k in self.keys:
      if self.parsed_data[k] is not None:
        self.real_values.append( self.parsed_data[k] )

    self.values_sum = float( sum( self.real_values ) )

    # Prepare numerical representation of keys for plotting
    self.num_keys = []
    if self.key_type == "string":
      self.string_map = {}
      next = 0
      for key in self.keys:
        self.string_map[key] = next
        self.num_keys.append( next )
        next += 1
    elif self.key_type == "time":
      self.num_keys = [ date2num( datetime.datetime.fromtimestamp( to_timestamp( key ) ) ) for key in self.keys ]
    elif self.key_type == "numeric":
      self.num_keys = [ float( key ) for key in self.keys ]

    self.min_value = float( min( self.real_values ) )
    self.max_value = float( max( self.real_values ) )
    self.min_key = self.keys[0]
    self.max_key = self.keys[-1]
    self.sum_value = float( sum( self.real_values ) )
    self.last_value = float( self.real_values[-1] )
    
    count = len( filter(lambda a: a != 0, self.real_values) )
    if count != 0:
      self.avg_nozeros = self.sum_value / float( count )
    else:
      self.avg_nozeros = 0
示例#7
0
  def makeNumKeys( self ):
    """ Make numerical representation of the graph keys suitable for plotting
    """

    self.all_num_keys = []
    if self.key_type == "string":
      self.all_string_map = {}
      next = 0
      for key in self.all_keys:
        self.all_string_map[key] = next
        self.all_num_keys.append( next )
        next += 1
    elif self.key_type == "time":
      self.all_num_keys = [ date2num( datetime.datetime.fromtimestamp( to_timestamp( key ) ) ) for key in self.all_keys ]
    elif self.key_type == "numeric":
      self.all_num_keys = [ float( key ) for key in self.all_keys ]

    self.min_num_key = min( self.all_num_keys )
    self.max_num_key = max( self.all_num_keys )
示例#8
0
  def makeNumKeys(self):
    """ Make numerical representation of the graph keys suitable for plotting
    """

    self.all_num_keys = []
    if self.key_type == "string":
      self.all_string_map = {}
      next = 0
      for key in self.all_keys:
        self.all_string_map[key] = next
        self.all_num_keys.append(next)
        next += 1
    elif self.key_type == "time":
      self.all_num_keys = [date2num(datetime.datetime.fromtimestamp(to_timestamp(key))) for key in self.all_keys]
    elif self.key_type == "numeric":
      self.all_num_keys = [float(key) for key in self.all_keys]

    self.min_num_key = min(self.all_num_keys)
    self.max_num_key = max(self.all_num_keys)
示例#9
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)
     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); ymin *= 1.1
   if self.prefs.has_key('log_yaxis'):
     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))     
示例#10
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))
示例#11
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.
    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. )
          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 = self.cmap, norm = self.norms,
                       boundaries = self.cbBoundaries,
                       values = self.cbValues,
                       ticks = self.cbTicks )
    cb.draw_all()
示例#12
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))
示例#13
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()
示例#14
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))
示例#15
0
文件: BarGraph.py 项目: vingar/DIRAC
    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))
示例#16
0
文件: Graph.py 项目: DIRACGrid/DIRAC
    def makeGraph(self, data, *args, **kw):

        start = time.time()

        # Evaluate all the preferences
        self.prefs = evalPrefs(*args, **kw)
        prefs = self.prefs

        if DEBUG:
            print "makeGraph time 1", time.time() - start
            start = time.time()

        if prefs.has_key("text_image"):
            self.makeTextGraph(str(prefs["text_image"]))
            return

        # Evaluate the number of plots and their requested layout
        metadata = prefs.get("metadata", {})
        plot_grid = prefs.get("plot_grid", "1:1")
        nx = int(plot_grid.split(":")[0])
        ny = int(plot_grid.split(":")[1])
        nPlots = nx * ny
        if nPlots == 1:
            if type(data) != types.ListType:
                data = [data]
            if type(metadata) != types.ListType:
                metadata = [metadata]
        else:
            if type(data) != types.ListType:
                # return S_ERROR('Single data for multiplot graph')
                print "Single data for multiplot graph"
                return
            if type(metadata) != types.ListType:
                metaList = []
                for _ in range(nPlots):
                    metaList.append(metadata)
                metadata = metaList

        # Initialize plot data
        graphData = []
        plot_prefs = []
        for i in range(nPlots):
            plot_prefs.append(evalPrefs(prefs, metadata[i]))
            gdata = GraphData(data[i])
            if i == 0:
                plot_type = plot_prefs[i]["plot_type"]
            if plot_prefs[i].has_key("sort_labels"):
                reverse = plot_prefs[i].get("reverse_labels", False)
                gdata.sortLabels(plot_prefs[i]["sort_labels"], reverse_order=reverse)
            if plot_prefs[i].has_key("limit_labels"):
                if plot_prefs[i]["limit_labels"] > 0:
                    gdata.truncateLabels(plot_prefs[i]["limit_labels"])
            if plot_prefs[i].has_key("cumulate_data"):
                gdata.makeCumulativeGraph()
            plot_title = plot_prefs[i].get("plot_title", "")
            if plot_title != "NoTitle":
                begin = ""
                end = ""
                if plot_prefs[i].has_key("starttime") and plot_prefs[i].has_key("endtime"):
                    begin = to_timestamp(plot_prefs[i]["starttime"])
                    end = to_timestamp(plot_prefs[i]["endtime"])
                elif gdata.key_type == "time":
                    begin = gdata.min_key
                    end = gdata.max_key
                if begin and end:
                    time_title = add_time_to_title(begin, end)
                    if plot_title:
                        plot_title += ":"
                    plot_prefs[i]["plot_title"] = plot_title + " " + time_title
            graphData.append(gdata)

        # Do not make legend for the plot with non-string keys (except for PieGraphs)
        if not graphData[0].subplots and graphData[0].key_type != "string" and not plot_type == "PieGraph":
            prefs["legend"] = False
        if prefs["legend"] and graphData[0].key_type != "string" and plot_type == "PieGraph":
            graphData[0].initialize(key_type="string")

        legend = Legend(graphData[0], None, prefs)
        self.figure = Figure()

        # Make Water Mark
        image = prefs.get("watermark", None)
        self.drawWaterMark(image)

        legend_ax, plot_axes = self.layoutFigure(legend)

        if DEBUG:
            print "makeGraph time layout", time.time() - start
            start = time.time()

        # Make plots
        for i in range(nPlots):
            plot_type = plot_prefs[i]["plot_type"]
            try:
                exec "import %s" % plot_type
            except ImportError, x:
                print "Failed to import graph type %s: %s" % (plot_type, str(x))
                return None

            ax = plot_axes[i]
            plot = eval("%s.%s(graphData[i],ax,plot_prefs[i])" % (plot_type, plot_type))
            plot.draw()
示例#17
0
文件: Graph.py 项目: DIRACGrid/DIRAC
    def makeGraph(self, data, *args, **kw):

        start = time.time()

        # Evaluate all the preferences
        self.prefs = evalPrefs(*args, **kw)
        prefs = self.prefs

        if DEBUG:
            print("makeGraph time 1", time.time() - start)
            start = time.time()

        if "text_image" in prefs:
            self.makeTextGraph(str(prefs["text_image"]))
            return

        # Evaluate the number of plots and their requested layout
        metadata = prefs.get("metadata", {})
        plot_grid = prefs.get("plot_grid", "1:1")
        nx = int(plot_grid.split(":")[0])
        ny = int(plot_grid.split(":")[1])
        nPlots = nx * ny
        if nPlots == 1:
            if not isinstance(data, list):
                data = [data]
            if not isinstance(metadata, list):
                metadata = [metadata]
        else:
            if not isinstance(data, list):
                # return S_ERROR('Single data for multiplot graph')
                print("Single data for multiplot graph")
                return
            if not isinstance(metadata, list):
                metaList = []
                for _ in range(nPlots):
                    metaList.append(metadata)
                metadata = metaList

        # Initialize plot data
        graphData = []
        plot_prefs = []
        for i in range(nPlots):
            plot_prefs.append(evalPrefs(prefs, metadata[i]))
            gdata = GraphData(data[i])
            if i == 0:
                plot_type = plot_prefs[i]["plot_type"]
            if "sort_labels" in plot_prefs[i]:
                reverse = plot_prefs[i].get("reverse_labels", False)
                gdata.sortLabels(plot_prefs[i]["sort_labels"],
                                 reverse_order=reverse)
            if "limit_labels" in plot_prefs[i]:
                if plot_prefs[i]["limit_labels"] > 0:
                    gdata.truncateLabels(plot_prefs[i]["limit_labels"])
            if "cumulate_data" in plot_prefs[i]:
                gdata.makeCumulativeGraph()
            plot_title = plot_prefs[i].get("plot_title", "")
            if plot_title != "NoTitle":
                begin = ""
                end = ""
                if "starttime" in plot_prefs[i] and "endtime" in plot_prefs[i]:
                    begin = to_timestamp(plot_prefs[i]["starttime"])
                    end = to_timestamp(plot_prefs[i]["endtime"])
                elif gdata.key_type == "time":
                    begin = gdata.min_key
                    end = gdata.max_key
                if begin and end:
                    time_title = add_time_to_title(begin, end)
                    if plot_title:
                        plot_title += ":"
                    plot_prefs[i]["plot_title"] = plot_title + " " + time_title
            graphData.append(gdata)

        # Do not make legend for the plot with non-string keys (except for PieGraphs)
        if not graphData[0].subplots and graphData[
                0].key_type != "string" and not plot_type == "PieGraph":
            prefs["legend"] = False
        if prefs["legend"] and graphData[
                0].key_type != "string" and plot_type == "PieGraph":
            graphData[0].initialize(key_type="string")

        legend = Legend(graphData[0], None, prefs)
        self.figure = Figure()

        # Make Water Mark
        image = prefs.get("watermark", None)
        self.drawWaterMark(image)

        legend_ax, plot_axes = self.layoutFigure(legend)

        if DEBUG:
            print("makeGraph time layout", time.time() - start)
            start = time.time()

        # Make plots
        for i in range(nPlots):
            plot_type = plot_prefs[i]["plot_type"]
            try:
                # TODO: Remove when we moved to python3
                exec("import %s" % plot_type)
            except ImportError:
                print("Trying to use python like import")
                try:
                    exec("from . import  %s" % plot_type)
                except ImportError as x:
                    print("Failed to import graph type %s: %s" %
                          (plot_type, str(x)))
                    return None

            ax = plot_axes[i]
            plot = eval("%s.%s(graphData[i],ax,plot_prefs[i])" %
                        (plot_type, plot_type))
            plot.draw()

        if DEBUG:
            print("makeGraph time plots", time.time() - start)
            start = time.time()

        # Make legend
        if legend_ax:
            legend.setAxes(legend_ax)
            legend.draw()

        if DEBUG:
            print("makeGraph time legend", time.time() - start)
            start = time.time()
示例#18
0
    def makeGraph(self, data, *args, **kw):

        start = time.time()

        # Evaluate all the preferences
        self.prefs = evalPrefs(*args, **kw)
        prefs = self.prefs

        if DEBUG:
            print "makeGraph time 1", time.time() - start
            start = time.time()

        if prefs.has_key('text_image'):
            self.makeTextGraph(str(prefs['text_image']))
            return

        # Evaluate the number of plots and their requested layout
        metadata = prefs.get('metadata', {})
        plot_grid = prefs.get('plot_grid', '1:1')
        nx = int(plot_grid.split(':')[0])
        ny = int(plot_grid.split(':')[1])
        nPlots = nx * ny
        if nPlots == 1:
            if not isinstance(data, list):
                data = [data]
            if not isinstance(metadata, list):
                metadata = [metadata]
        else:
            if not isinstance(data, list):
                #return S_ERROR('Single data for multiplot graph')
                print 'Single data for multiplot graph'
                return
            if not isinstance(metadata, list):
                metaList = []
                for _ in range(nPlots):
                    metaList.append(metadata)
                metadata = metaList

        # Initialize plot data
        graphData = []
        plot_prefs = []
        for i in range(nPlots):
            plot_prefs.append(evalPrefs(prefs, metadata[i]))
            gdata = GraphData(data[i])
            if i == 0: plot_type = plot_prefs[i]['plot_type']
            if plot_prefs[i].has_key('sort_labels'):
                reverse = plot_prefs[i].get('reverse_labels', False)
                gdata.sortLabels(plot_prefs[i]['sort_labels'],
                                 reverse_order=reverse)
            if plot_prefs[i].has_key('limit_labels'):
                if plot_prefs[i]['limit_labels'] > 0:
                    gdata.truncateLabels(plot_prefs[i]['limit_labels'])
            if plot_prefs[i].has_key('cumulate_data'):
                gdata.makeCumulativeGraph()
            plot_title = plot_prefs[i].get('plot_title', '')
            if plot_title != "NoTitle":
                begin = ''
                end = ''
                if plot_prefs[i].has_key(
                        'starttime') and plot_prefs[i].has_key('endtime'):
                    begin = to_timestamp(plot_prefs[i]['starttime'])
                    end = to_timestamp(plot_prefs[i]['endtime'])
                elif gdata.key_type == "time":
                    begin = gdata.min_key
                    end = gdata.max_key
                if begin and end:
                    time_title = add_time_to_title(begin, end)
                    if plot_title:
                        plot_title += ":"
                    plot_prefs[i]['plot_title'] = plot_title + ' ' + time_title
            graphData.append(gdata)

        # Do not make legend for the plot with non-string keys (except for PieGraphs)
        if not graphData[0].subplots and graphData[
                0].key_type != 'string' and not plot_type == 'PieGraph':
            prefs['legend'] = False
        if prefs['legend'] and graphData[
                0].key_type != 'string' and plot_type == 'PieGraph':
            graphData[0].initialize(key_type='string')

        legend = Legend(graphData[0], None, prefs)
        self.figure = Figure()

        # Make Water Mark
        image = prefs.get('watermark', None)
        self.drawWaterMark(image)

        legend_ax, plot_axes = self.layoutFigure(legend)

        if DEBUG:
            print "makeGraph time layout", time.time() - start
            start = time.time()

        # Make plots
        for i in range(nPlots):
            plot_type = plot_prefs[i]['plot_type']
            try:
                exec "import %s" % plot_type
            except ImportError, x:
                print "Failed to import graph type %s: %s" % (plot_type,
                                                              str(x))
                return None

            ax = plot_axes[i]
            plot = eval("%s.%s(graphData[i],ax,plot_prefs[i])" %
                        (plot_type, plot_type))
            plot.draw()
示例#19
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))
示例#20
0
文件: Graph.py 项目: DIRACGrid/DIRAC
  def makeGraph(self, data, *args, **kw):

    start = time.time()

    # Evaluate all the preferences
    self.prefs = evalPrefs(*args,**kw)
    prefs = self.prefs

    if DEBUG:
      print "makeGraph time 1",time.time()-start
      start = time.time()

    if prefs.has_key('text_image'):
      self.makeTextGraph(str(prefs['text_image']))
      return

    # Evaluate the number of plots and their requested layout
    metadata = prefs.get('metadata',{})
    plot_grid = prefs.get('plot_grid','1:1')
    nx = int(plot_grid.split(':')[0])
    ny = int(plot_grid.split(':')[1])
    nPlots = nx*ny
    if nPlots == 1:
      if not isinstance( data, list ):
        data = [data]
      if not isinstance(metadata, list):
        metadata = [metadata]
    else:
      if not isinstance( data, list ):
        #return S_ERROR('Single data for multiplot graph')
        print 'Single data for multiplot graph'
        return
      if not isinstance(metadata, list):
        metaList = []
        for _ in range( nPlots ):
          metaList.append(metadata)
        metadata = metaList

    # Initialize plot data
    graphData = []
    plot_prefs = []
    for i in range(nPlots):
      plot_prefs.append(evalPrefs(prefs,metadata[i]))
      gdata = GraphData(data[i])
      if i == 0: plot_type = plot_prefs[i]['plot_type']
      if plot_prefs[i].has_key('sort_labels'):
        reverse = plot_prefs[i].get( 'reverse_labels', False )
        gdata.sortLabels(plot_prefs[i]['sort_labels'], reverse_order = reverse )
      if plot_prefs[i].has_key('limit_labels'):
        if plot_prefs[i]['limit_labels'] > 0:
          gdata.truncateLabels(plot_prefs[i]['limit_labels'])
      if plot_prefs[i].has_key('cumulate_data'):
        gdata.makeCumulativeGraph()
      plot_title = plot_prefs[i].get('plot_title','')
      if plot_title != "NoTitle":
        begin = ''
        end = ''
        if plot_prefs[i].has_key('starttime') and plot_prefs[i].has_key('endtime'):
          begin = to_timestamp(plot_prefs[i]['starttime'])
          end = to_timestamp(plot_prefs[i]['endtime'])
        elif gdata.key_type == "time" :
          begin = gdata.min_key
          end = gdata.max_key
        if begin and end:
          time_title = add_time_to_title(begin,end)
          if plot_title:
            plot_title += ":"
          plot_prefs[i]['plot_title'] = plot_title+' '+time_title
      graphData.append(gdata)

    # Do not make legend for the plot with non-string keys (except for PieGraphs)
    if not graphData[0].subplots and graphData[0].key_type != 'string' and not plot_type == 'PieGraph':
      prefs['legend'] = False
    if prefs['legend'] and graphData[0].key_type != 'string' and plot_type == 'PieGraph':
      graphData[0].initialize(key_type='string')

    legend = Legend(graphData[0],None,prefs)
    self.figure = Figure()

    # Make Water Mark
    image = prefs.get('watermark',None)
    self.drawWaterMark(image)

    legend_ax, plot_axes = self.layoutFigure(legend)

    if DEBUG:
      print "makeGraph time layout",time.time()-start
      start = time.time()

    # Make plots
    for i in range(nPlots):
      plot_type = plot_prefs[i]['plot_type']
      try:
        exec "import %s" % plot_type
      except ImportError, x:
        print "Failed to import graph type %s: %s" % ( plot_type, str( x ) )
        return None

      ax = plot_axes[i]
      plot = eval("%s.%s(graphData[i],ax,plot_prefs[i])" % (plot_type,plot_type) )
      plot.draw()
示例#21
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))