[Pyx-user] Re: bars with errors From: Marko Vendelin - 2004-04-26 20:29:38 ```Thanks, the bug is fixed, indeed :). > For 0.7 I'm working to allow several styles within one plot command. > I want to allow errorbars at bar graphs without further thoughts: > > g.plot(graph.data.list(xname=1, y=2, dy=3), [graph.style.bar(), graph.style.errorbar()]) I guess it should be g.plot(graph.data.list(xname=1, y=2, dy=3), [graph.style.bar(), graph.style.symbol()]) ? > I also want to enable insertion of text at the top (or another > position) of a bar graph and others. Another gain will be an easier > extention of existing styles without copying much code as it currently > can be, because graph styles are still quite monolithic. So you have > to wait for another two or three months. (Beside that I could explain > you the bar dist etc. when you ask questions about it ...) Excellent plan! OK, I'll ask about positioning of the bars (to draw bars with errors during 2-3 month). It seems that, in the simplest case, centers of the bars are at positions 1, 2, 3, ... and the limits of the axis are min=0.5 to max=N+0.5 (N is the number of bars). Situation is somewhat more difficult if there are multiple bars per each category (as in the second plot of examples/bar.py). For example, if we have NSubCols in each of the groups of bars, then the center of each of the subbars is at x = j + 1 + (i - NSubCols/2.0 + 0.5)*w where j is index of the group (from 0 to N-1), i is the index of the subbar, and w is the width of the subbar. The width of the subbar is determined by NSubCols and argument dist given to axis.bar() as follows: w = 1.0 / (NSubCols + dist) However, these formula work only in the case if dist for multisubaxis is set equal to zero. How should I modify these formula to get them work on general case (with the both dist given for axis and multisubaxis)? Best wishes, Marko ```
 [Pyx-user] Re: bars with errors From: Marko Vendelin - 2004-04-26 20:29:38 ```Thanks, the bug is fixed, indeed :). > For 0.7 I'm working to allow several styles within one plot command. > I want to allow errorbars at bar graphs without further thoughts: > > g.plot(graph.data.list(xname=1, y=2, dy=3), [graph.style.bar(), graph.style.errorbar()]) I guess it should be g.plot(graph.data.list(xname=1, y=2, dy=3), [graph.style.bar(), graph.style.symbol()]) ? > I also want to enable insertion of text at the top (or another > position) of a bar graph and others. Another gain will be an easier > extention of existing styles without copying much code as it currently > can be, because graph styles are still quite monolithic. So you have > to wait for another two or three months. (Beside that I could explain > you the bar dist etc. when you ask questions about it ...) Excellent plan! OK, I'll ask about positioning of the bars (to draw bars with errors during 2-3 month). It seems that, in the simplest case, centers of the bars are at positions 1, 2, 3, ... and the limits of the axis are min=0.5 to max=N+0.5 (N is the number of bars). Situation is somewhat more difficult if there are multiple bars per each category (as in the second plot of examples/bar.py). For example, if we have NSubCols in each of the groups of bars, then the center of each of the subbars is at x = j + 1 + (i - NSubCols/2.0 + 0.5)*w where j is index of the group (from 0 to N-1), i is the index of the subbar, and w is the width of the subbar. The width of the subbar is determined by NSubCols and argument dist given to axis.bar() as follows: w = 1.0 / (NSubCols + dist) However, these formula work only in the case if dist for multisubaxis is set equal to zero. How should I modify these formula to get them work on general case (with the both dist given for axis and multisubaxis)? Best wishes, Marko ```
 Re: [Pyx-user] Re: bars with errors From: Andre Wobst - 2004-04-27 06:13:18 ```Hi, On 26.04.04, Marko Vendelin wrote: > > For 0.7 I'm working to allow several styles within one plot command. > > I want to allow errorbars at bar graphs without further thoughts: > > > > g.plot(graph.data.list(xname=1, y=2, dy=3), [graph.style.bar(), graph.style.errorbar()]) > > I guess it should be > > g.plot(graph.data.list(xname=1, y=2, dy=3), [graph.style.bar(), graph.style.symbol()]) ? Well, I thought about doing it a bit differently. Currently the base style for drawing symbols, lines, errorbars is symbolline (this style can be appended to add text at a symbol, for example, but beyond that it is quite monolithic). This symbolline style does at least five independend things, which I want to split into several styles. These are: pointpos (handling the position of a data point), rangepos (handling the position of an area around a point -- like an error range), stroking of a symbol at a point position, stroking lines to connect point positions, and stroking errorbars for the given ranges. This is already done in CVS, while not all parts are already working properly. In the future I want to to be able to say either: g.plot(graph.data.list(x=1, y=2), [graph.style.symbol()]) or g.plot(graph.data.list(x=1, y=2, dy=3), [graph.style.symbol(), graph.style.errorbar()]) Note first, that we do not need to specify pointpos and rangepos within the styles (this is not yet implemented in CVS). When a style requests a pointpos information an no other preceding style provides this feature, it would automatically add the pointpos style before, which does some calculations and provides position information, but does not actually create any output. The same would be the case in the second example for rangepos due to the errorbar style. Now, in the first case a dy=3 would result in an error, because no style actually takes care on the dy data provided. Finally, the bar style should provide a pointpos at the top of the bars. When you combine this with the errorbar style, you can just add a dy value and use the errorbar style. Concerning the bars there are some open questions: how can you manage several point positions (due to stacked bars). This is totally open, how to solve this. Another idea is to write some text within the bar together with the bar value at the top of the bar). We'll see. I think, these open questions are not crucial for a 0.7 ... I want to proceed to develop the basic infrastructure and there surely will be a solution in the end for those more complicated cases. May be text within the bar are just a special case handled within the bar style. > However, these formula work only in the case if dist for multisubaxis is > set equal to zero. How should I modify these formula to get them work on > general case (with the both dist given for axis and multisubaxis)? The point is, that you have several different dist variables then. This is because you can build nested baraxis with any level of depths. (However, the bar style can handle only 1 nesting level.) Let me tell you the base procedure: A bar axis instance gets a list of values to identify a position on the axis, not just a single value. It takes the first value of the list, which is considered to be a name (thus it can be a string or an integer or whatever else). The axis stores a list of valid names and searches for the position of the name in this list. This is the position to be taken into account, but this position is not a point, but it identifies a range. So how is this range created: +----------+ +----------+ | | | | | | | | | | | | | | | | | | | | | | | | |---------+----------+----------+----------+---------| firstdist subaxis dist subaxis lastdist width width The values of firstdist, dist, lastdist and the two subaxis widths (in this example) are plain numbers. The ranges are given by ratios between these numbers. Now, what are the subaxis widths? When no subaxis is given, the subaxis width is 1. When a subaxis is given, it has a width itself. In case of a sub-baraxis the width is the sum of all the widths within this sub-baraxis. And to make the positioning really complicated, each of the subaxes can be a independend instance of baraxis. Then the width of the subaxes can be different from each other due to having a different number of bars per name. But still, each of the subaxis instances does have a width, which is calculated by summing up the values as shown. The parent bar axis takes all these widths and build its range information out of that ... and thats basically all. André -- by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ ```