Node:interval_bar_plot, Next:, Previous:bar_plot, Up:Top



Interval bar Plots

An interval bar plot is a special kind of bar plot that draws an alternating sequence of bars. intvlbartestv.png

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)))

ar.add_plot(interval_bar_plot.T(line_styles = [line_style.default, None],
                                fill_styles = [fill_style.blue, None],
                                label="bar", hcol=2, cluster=(1,2)))

ar.draw()



bcol type: int Attribute
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 Attribute
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: number Attribute
Default: 0. The separation between clustered boxes. The unit is points.

data type: any Attribute
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 Attribute
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 font.

data_label_offset type: (x,y) Attribute
Default: (0, 5). The location of data labels relative to the sample point. See also attribute data_label_format.

direction type: str Attribute
Default: "vertical". The direction the growth of the bars. The value is either 'horizontal' or 'vertical'.

fill_styles type: list Attribute
Default: ['<function <lambda> at 0x8289ecc>', '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 fill_style.

hcol type: int Attribute
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 Attribute
Default: "???". The label to be displayed in the legend. See legend., See font.

line_styles type: list Attribute
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 Attribute
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: number Attribute
Default: 5. Width of each box. The unit is in points.