9 Line and scatter plots
Description: Line and scatter plots
Keywords: pychart

#
9 Line and scatter plots

class `line_plot.T`
  This class raws a line plot. By specifying None to its line style, you can also draw a scatter plot.

  Sample line plot

  Below is the source code that produces the above chart. /home/ysaito/pychart/demos/linetest3.py

      from pychart import *

      theme.get_options()

      data = chart_data.read_csv("lines.csv")

      xaxis=axis.X(label="X", tic_interval=10)
      yaxis=axis.Y(label="Y", tic_interval=10)
      ar = area.T(x_range=(0,100), y_range=(0,100), x_axis=xaxis, y_axis=yaxis)
      eb = error_bar.error_bar2(tic_len=5, hline_style=line_style.gray50)
      ar.add_plot(line_plot.T(label="foo", data=data, error_bar=eb, y_error_minus_col=3),
                  line_plot.T(label="bar", data=data, ycol=2, error_bar=eb, y_error_minus_col=3))
      ar.draw()

      tb = text_box.T(loc=(40, 130), text="This is\nimportant!", line_style=None)
      tb.add_arrow((ar.x_pos(data[6][0]), ar.y_pos(data[6][1])), "cb")
      tb.draw()

      ar = area.T(loc=(200, 0), x_range=(0,100), y_range=(0,100),
                  x_axis=xaxis, y_axis=yaxis, legend=legend.T())
      ar.add_plot(line_plot.T(label="foo", data=data, data_label_format="/8{}%d"),
                  line_plot.T(label="bar", data=data, ycol=2))
      ar.draw()

  Sample scatter plot

  Below is the source code that produces the above chart. /home/ysaito/pychart/demos/scattertest.py

      from pychart import *
      import whrandom

      def randomdata():
          data = []
          for i in range(0, 30):
              data.append((whrandom.random() * 1000, whrandom.random() * 1000))
          return data

      theme.get_options()
      chart_object.set_defaults(line_plot.T, line_style=None)

      tick1 = tick_mark.Circle(size=2)
      tick2 = tick_mark.Circle(size=2, fill_style=fill_style.black)
      xaxis = axis.X(label="foo", format="/a-60{}%d")
      yaxis = axis.Y(label="bar")

      ar = area.T(x_axis=xaxis, y_axis=yaxis,
                  x_grid_interval=100, x_grid_style=line_style.gray70_dash3,
                  legend = legend.T(loc=(350, 50)), loc = (0, 0))

      ar.add_plot(line_plot.T(label="plot1", data=randomdata(), tick_mark=tick1))
      ar.add_plot(line_plot.T(label="plot2", data=randomdata(), tick_mark=tick2))
      ar.draw()

      xaxis = axis.X(label="foo", format="/a-30{}%d")
      yaxis = axis.Y(label="bar")
      ar = area.T(x_axis=xaxis, y_axis=yaxis,
                  x_coord=log_coord.T(), y_coord=log_coord.T(), loc = (200, 0),
                  legend = None)

      ar.add_plot(line_plot.T(label="plot1", data=randomdata(), tick_mark=tick1))
      ar.add_plot(line_plot.T(label="plot2", data=randomdata(), tick_mark=tick2))
      ar.draw()

`data`
  Type: any Default: None.

  Specifies the data points. See Section 5

`data_label_format`
  Type: printf format string Default: None.

  The format string for the label printed beside a sample point. It can be a `printf' style format string, or a two-parameter function that takes the (x, y) values and returns a string. The appearance of the string produced here can be controlled using escape sequences. See Section 17

`data_label_offset`
  Type: (x,y) Default: (0, 5).

  The location of data labels relative to the sample point. Meaningful only when data_label_format != None.

`error_bar`
  Type: error_bar.T ( see Section 9.2) Default: None.

  The style of the error bar. See Section 9.2

`label`
  Type: str Default: "???".

  The label to be displayed in the legend. See Section 6.3, See Section 17

`line_style`
  Type: line_style.T (see Section 14) Default: By default, a style is picked from standard styles round-robin. See Section 14.

  The style of the line.

`tick_mark`
  Type: tick_mark.T ( see Section 9.1) Default: None.

  Tick marks to be displayed at each sample point. See Section 9.1

`xcol`
  Type: int Default: 0.

  The column, within attribute "data", from which the X values of sample points are extracted. See Section 5

`y_error_minus_col`
  Type: int Default: 2.

  The column (within "data") from which the depth of the errorbar is extracted. Meaningful only when error_bar != None. See Section 9.2

`y_error_plus_col`
  Type: int Default: -1.

  The column (within "data") from which the height of the errorbar is extracted. Meaningful only when error_bar != None. See Section 9.2

`y_qerror_minus_col`
  Type: int Default: -1.

  See Section 9.2

`y_qerror_plus_col`
  Type: int Default: -1.

  See Section 9.2

`ycol`
  Type: int Default: 1.

  The column, within attribute "data", from which the Y values of sample points are extracted. See Section 5

Subsections

- 9.1 Tick marks
- 9.2 Error bars