#
8 Interval bar plots

class `interval_bar_plot.T`
  An interval bar plot is a special kind of bar plot that draws an alternating sequence of bars.

  Sample interval bar chart

  Below is the source code that produces the above chart. ../demos/intvlbartestv.py

      from pychart import *
      theme.get_options()

      data = [("Foo", (10, 7, 10, 5, 5, 12, 13, 5, 10, 3),
               (7,10,8,16,9,3)),
              ("Bar", (5, 10, 12, 10, 9, 3),
               (10,10,13,6,9,13),)]

      ar = area.T(y_coord = category_coord.T(data, 0),
                  x_grid_style=line_style.gray50_dash1,
                  x_grid_interval=20, x_range = (0,100),
                  x_axis=axis.X(label="X label"),
                  y_axis=axis.Y(label="Y label"),
                  legend = legend.T(loc=(80, 40)))

      chart_object.set_defaults(interval_bar_plot.T, direction="horizontal",
                                width=3, cluster_sep = 5, data=data)
      ar.add_plot(interval_bar_plot.T(line_styles = [line_style.default, None],
                                      fill_styles = [fill_style.red, None],
                                      label="foo", cluster=(0,2)),
                  interval_bar_plot.T(line_styles = [line_style.default, None],
                                      fill_styles = [fill_style.blue, None],
                                      label="bar", hcol=2, cluster=(1,2)))

      can = canvas.default_canvas()
      can.set_title("Interval bar test")
      can.set_author("John Doe")
      ar.draw()

The list the attributes understood by an `interval_bar_plot.T` object:

`bcol`
  Type: int Default: 0.

  Specifies the column from which base values (i.e., X values when attribute "direction" is "vertical", Y values otherwise) are extracted. The combination of "data", "bcol", and "hcol" attributes defines the set of boxes drawn by this chart. See also the descriptions of the 'bcol' and 'data' attributes.

`cluster`
  Type: tuple Default: (0, 1).

  This attribute is used to cluster multiple bar plots side by side in a single chart. The value should be a tuple of two integers. The second value should be equal to the total number of bar plots in the chart. The first value should be the relative position of this chart; 0 places this chart the leftmost, and N-1 (where N is the 2nd value of this attribute) places this chart the rightmost. Consider the below example:

          a = area.T(...)
          p1 = interval_bar_plot.T(data = [[1, [20,10]][2,[30,5]]], cluster=(0,2))
          p2 = interval_bar_plot.T(data = [[1,[25,11,2]],[2,[10,5,3]]], cluster=(1,2))
          a.add_plot(p1, p2)
          a.draw()

  In this example, one group of bars will be drawn side-by-side at position x=1. Other two bars will be drawn side by side at position x=2. See also the description of attribute "cluster" for bar_plot.T.

`cluster_sep`
  Type: length in points ( See Section 4) Default: 0.

  The separation between clustered boxes. The unit is points.

`data`
  Type: any Default: None.

  Specifes data points. Unlike other types of charts, the "hcol"th column of the data must be a sequence of numbers, not just a single number. See also the description of "hcol".

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

  The format string for the label displayed besides each bar. It can be a `printf' style format string, or a two-parameter function that takes (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) or None Default: (0, 5).

  The location of data labels relative to the sample point. See also attribute data_label_format.

`direction`
  Type: str Default: "vertical".

  The direction the growth of the bars. The value is either 'horizontal' or 'vertical'.

`fill_styles`
  Type: list Default: ['function <lambda at 0x403cd534>', 'None'].

  List of fill styles for bars. The style of each bar is chosen in a round-robin fashion, if the number of elements in "line_styles" is smaller than actual number of boxes. If this attribute is omitted, a style is picked from standard styles round-robin. See Section 16.

`hcol`
  Type: int Default: 1.

  The column from which the base and height of bars are extracted. See the below example:

                    d = [[5,[10,15,22]], [7,[22,23,5,10]], [8,[25,3]]]
                    p = interval_bar_plot.T(data = d, bcol = 0, hcol = 1)

  Here, three sequence of bars will be drawn. The X locations of the bars will be 5, 7, and 8. For example, at location X=7, three bars are drawn, one corresponding to Y values of 22 to 45 (=22+23), and the second one for values 45 to 50, and the third one for values 50 to 60. The line and fill styles of the bars are picked in a round-robin fashion from attributes "line_styles" and "fill_styles".

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

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

`line_styles`
  Type: list Default: ['line_style.black', 'None'].

  The list of line styles for bars. The style of each bar is chosen in a round-robin fashion, if the number of elements in "line_styles" is smaller than actual number of boxes.

`stack_on`
  Type: any Default: None.

  The value must be either None or bar_plot.T. If not None, bars of this plot are stacked on top of another bar plot.

`width`
  Type: length in points ( See Section 4) Default: 5.

  Width of each box. The unit is in points.