rework the bar graph examples for 0.9
[PyX/mjg.git] / examples / bargraphs / compare.txt
blob137db7a67c3b0478117229ccc8e536a67d455e81
1 Comparing bars
3 To draw bars side by side to show differences for the same value you basically
4 need to replace the bar axis by a nestedbar axis and adjust the data to that
5 nesting. ... The later is done by providing a tuple of two to the nested bar axis
6 instead of a single value. The first value provided by the tuple is used to
7 select a subaxis at the nestedbar axis and the second value is used on that
8 selected bar axis.
10 ! You can replace `0` and `1` in the values provided to the xname parameter of
11 the data by other hashable objects as long as they differ. The order of the
12 bars at the subaxis does not depend by their selection value (as for bar axes
13 in general), but by the order data is added to the bar axes. So when you
14 exchange `0` and `1` in the xname parameter nothing will change in the output.
16 !! You can also use the same value (i.e. an object with the same hash value)
17 for the subselection of the nested bar axis. Then the bars will overpaint each
18 other and by proper ordering of the data you can fake stacked bars by that.
20 !! Guess what happens when you change the values provided to the xname
21 parameter of the data from `"$1, 0"` and `"$1, 1"` to `"0, $1"` and `"1, $1"`,
22 respectively. The answer is, that all blue bars will be shown on one subaxis
23 and all red bars will be shown on another subaxis.
25 !! A nested bar axis is totally equivalent to a regular bar axis except for its
26 default value for the defaultsubaxis parameter in the constructor. While this
27 defaultsubaxis parameter is a special instance of a linear axis for the bar
28 axis, for a nestedbar axis its a special instance of another bar axis. The
29 nesting of bar axes is not limited to a single level: You can nest bar axes
30 into each other to any level you want. Providing explicit subaxes for certain
31 values, the nesting levels can even vary for the differen subaxes. (This is
32 totally crazy.)
34 ! In PyX versions prior to PyX 0.9 the creation of nested data for the bar axes
35 was hidden inside the graph styles (with the limitation as we use it here in
36 this example: adding precisely a single nesting level when passing multiple
37 data to a single set of styles). In previous versions we didn't had the
38 possibility to simply generate tuples for data columns. The automatism was
39 removed completely, which makes ''all'' the bended sections above possible.
40 This is a quite incompatible but absolutely necessary change.