## Re: [PyX-user] Re: graph question

 Re: [PyX-user] Re: graph question From: Andre Wobst - 2005-09-19 10:36:15 ```Hi, On 16.09.05, Alan G Isaac wrote: > On Fri, 16 Sep 2005, Alan G Isaac apparently wrote: > > My approach has been to use graphxy and start turning > > things off, but this seems backwards, and I have run into > > a few problems this way. > > I should be more specific. > Suppose I have used graphxy to produce a graph, > with axes provided by axis.linear. > Now I want a graph that is just the same with one exception: > I want to rescale the y-axis (without changing its min and > max), so that *everything* painted in the graph has the new > scale (e.g., a former circle becomes an oval). How? You can add such a transformation while inserting a canvas into another canvas as in the following code fragment: subcanvas = canvas.canvas() subcanvas.stroke(path.circle(0, 0, 1)) c.insert(subcanvas([trafo.scale(1, 2)])) This will create an ellipse in c. Since in you case you want to stroke something into the graph, but transforming it before it get's stroked, such a subcanvas seams to be appropriate. (When you would rescale the full graph, all the axes etc. would be affected as well.) > I suppose I am asking: can I do all my drawing in axis > coordinates? No, unfortunately you can't directly. The whole path system does not know anything about graphs. There are only a very few methods in the graph, which work on graph coordinates and which are used by the styles to add something to the graph canvas. Note, that the graph coordinates are again different from the axis coodinates. You could provide yourself with a simple set of path functions which take values in problem coordinates and return the proper paths. Those methods are easily implemented and should be handy for your ideas. I'm not sure whether the graph system is really useful for you, but you may (as it sounds) just use it to draw the axis part of your figure ... why shouldn't you? André -- by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ ```

 [PyX-user] graph question From: Alan G Isaac - 2005-09-16 22:45:23 ```What is the smart way to do this? I need a series of graphs that share the following. Figures not data are plotted. Each graph shows an x-axis (bottom) and a y-axis (left) only. These axes are labeled. Figures are drawn only in the positive quadrant. No automatic ticking, but want to use ticks to place text related to the figures. I may need two version of some graphs: a square version (aspect ratio preserving) and a rectangular=20 version (only relative position matters). So I'd like to exploit pyx.graph.axis, I believe, but in a minimalist way. My approach has been to use=20 graphxy and start turning things off, but this seems backwards, and I have run into a few problems this way. Thank you, Alan Isaac ```
 [PyX-user] Re: graph question From: Alan G Isaac - 2005-09-17 02:16:07 ```On Fri, 16 Sep 2005, Alan G Isaac apparently wrote: > My approach has been to use graphxy and start turning > things off, but this seems backwards, and I have run into > a few problems this way. I should be more specific. Suppose I have used graphxy to produce a graph, with axes provided by axis.linear. Now I want a graph that is just the same with one exception: I want to rescale the y-axis (without changing its min and max), so that *everything* painted in the graph has the new scale (e.g., a former circle becomes an oval). How? I suppose I am asking: can I do all my drawing in axis coordinates? Thanks, Alan Isaac ```
 Re: [PyX-user] Re: graph question From: Andre Wobst - 2005-09-19 10:36:15 ```Hi, On 16.09.05, Alan G Isaac wrote: > On Fri, 16 Sep 2005, Alan G Isaac apparently wrote: > > My approach has been to use graphxy and start turning > > things off, but this seems backwards, and I have run into > > a few problems this way. > > I should be more specific. > Suppose I have used graphxy to produce a graph, > with axes provided by axis.linear. > Now I want a graph that is just the same with one exception: > I want to rescale the y-axis (without changing its min and > max), so that *everything* painted in the graph has the new > scale (e.g., a former circle becomes an oval). How? You can add such a transformation while inserting a canvas into another canvas as in the following code fragment: subcanvas = canvas.canvas() subcanvas.stroke(path.circle(0, 0, 1)) c.insert(subcanvas([trafo.scale(1, 2)])) This will create an ellipse in c. Since in you case you want to stroke something into the graph, but transforming it before it get's stroked, such a subcanvas seams to be appropriate. (When you would rescale the full graph, all the axes etc. would be affected as well.) > I suppose I am asking: can I do all my drawing in axis > coordinates? No, unfortunately you can't directly. The whole path system does not know anything about graphs. There are only a very few methods in the graph, which work on graph coordinates and which are used by the styles to add something to the graph canvas. Note, that the graph coordinates are again different from the axis coodinates. You could provide yourself with a simple set of path functions which take values in problem coordinates and return the proper paths. Those methods are easily implemented and should be handy for your ideas. I'm not sure whether the graph system is really useful for you, but you may (as it sounds) just use it to draw the axis part of your figure ... why shouldn't you? André -- by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ ```
 Re[2]: [PyX-user] Re: graph question From: Alan G Isaac - 2005-09-19 14:44:19 ```Thanks. This helps me understand PyX a bit better. I have two embarrasingly simple questions: If I want a y-axis title (graph.axis.linear) just above the end of the axis, how to - left align the title to the leftmost tick position, or - center the title over the axis I understand the vertical placement, with 'titlepos', but the horizontal placement seems hard to override. Likewise, if I want the x-axis title to be right justified rather than centered at its 'titlepos', how do I request that? Now to respond to your post: Question: When you speak of the "problem coordinates", do you mean the default user coordinate system? Explanation: Why I'm using graphxy: - axes - manual ticks - titles - ability to draw relative to graph using 'pos' The last provides great flexibility for changing the aspect ratio of the graph while keeping everything else the "same", especially when some objects should not be transformed. Of course this could be done as well using a parameter or two, but I am finding graphxy to work rather nicely this way. For objects that should be transformed, inserting a transformed canvas is useful. Thanks for your help (and for this great tool). Cheers, Alan PS I'll get back to you with a stripped down TeX example as you requested. ```
 Re: [PyX-user] Re: graph question From: Andre Wobst - 2005-09-19 16:51:40 ```Hi, On 19.09.05, Alan G Isaac wrote: > Thanks. This helps me understand PyX a bit better. > > I have two embarrasingly simple questions: > > If I want a y-axis title (graph.axis.linear) just above the > end of the axis, how to > - left align the title to the leftmost tick position, or > - center the title over the axis > I understand the vertical placement, with 'titlepos', but > the horizontal placement seems hard to override. The problem is, that the placement of the title takes into account the labels of the ticks and it's difficult to get rid of that. While one could argue, that the behaviour is not wanted all the time, the question is what a useful alternative could look like. When I designed the graph system my idea was to not spend too many parameters for the painter. Instead, one could have different painters for different kind of text placement (and other features). Still, this is perfectly true, but beside the default painters there aren't much alternatives distributed with PyX. Since creating/appding/personalizing of the painters might not be something you're interested in (although it's not that complicated; but the mayor problem is that the painters are not exactly build out of tiny, simple, independend parts), the question is, what's best for you at the moment and for the whole PyX framework in the future. For you the most easiest thing is certainly to place the text manually, especially since you're defining the position where you want to place the tick quite well. For the PyX framework the question renders a bit more complicated. If think of the concept of decorators, the axis painters are such decorators for a long time already, using some path description parameters and some other data they somehow recieve. I should also emphazise, that the painters are a much older construction than decorators. But still, the question is, whether (some kind of special) decorators could help to modularize the whole thing. In fact, your task can already very comfortable be solved at the current CVS version along the following lines: from pyx import * from pyx.graph.axis import lin from pyx.graph.axis.painter import regular g = graph.graphxy(width=10, x=lin(min=0, max=10), x2=None, y=lin(min=0, max=10, painter=regular(basepathattrs=[deco.text("text on top", arclenfromend=0, angle=90)])), y2=None) g.writeEPSfile("toptext") The most interesting thing is, that the text decorator is very simple, contains only a few lines and is absolutely general purpose (doesn't only work for axes). Moreover, when we would use those decorators instead of the painters, the whole painter concept with the complicated argument structure could be removed. However, this would be a serious change ... in some sence it is comparable with the break up of the graph styles, which OTOH really was a very good thing. What do you guys think about this overall. It might be something we should discuss in detail and think about all the implications ... > Now to respond to your post: > > Question: > When you speak of the "problem coordinates", do you mean the > default user coordinate system? No, I meant the coordinates the data is given in, i.e. the values as stated on the axes. > Explanation: > Why I'm using graphxy: > - axes > - manual ticks > - titles > - ability to draw relative to graph using 'pos' > > The last provides great flexibility for changing the > aspect ratio of the graph while keeping everything > else the "same", especially when some objects should > not be transformed. Of course this could be done > as well using a parameter or two, but I am finding > graphxy to work rather nicely this way. > > For objects that should be transformed, inserting > a transformed canvas is useful. Thanks for your help > (and for this great tool). It's a very interesting and fruitful discussion to me as well ... André -- by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ ```
 Re[2]: [PyX-user] Re: graph question From: Alan G Isaac - 2005-09-19 21:19:32 ```On Mon, 19 Sep 2005, Andre Wobst apparently wrote:=20 > painter=3Dregular(basepathattrs=3D[deco.text("text on top", arclenfromend= =3D0, angle=3D90)])), y2=3DNone)=20 I see how this would address my title placement problem. I also like the idea a *lot* (as a non-programmer/user), and it has lots of nice general uses, especially if the text can have LaTeX attributes, for labeling paths. But since we are speaking of axis titles let me add a new=20 problem to the mix: A pretty good match to the above syntax: sometimes it is=20 nice to put an axis label on the horizontal axis with [text.parbox(width), text.valign.middle] A problem for the above syntax: sometimes it is nice to=20 place just above the end of the y-axis a multiline title=20 (parbox) left justified to match the leftmost-extending=20 tick. Anyway, you told me the right strategy for current problem: I should just place the text where I want it. Thanks, Alan ```
 Re: [PyX-user] Re: graph question From: Andre Wobst - 2005-09-22 13:33:35 ```Hi, On 19.09.05, Alan G Isaac wrote: > I see how this would address my title placement problem. > I also like the idea a *lot* (as a non-programmer/user), > and it has lots of nice general uses, especially if the > text can have LaTeX attributes, for labeling paths. At least the version I've checked into the CVS has a textattrs keyword as well, so yes, you can do that. BTW, Jörg, you may take a look to deco.text, where different relative positions for an object at a path can be given. Maybe that's something we should do for the "arrow in the middle" we just have in a different thread. > But since we are speaking of axis titles let me add a new > problem to the mix: > A pretty good match to the above syntax: sometimes it is > nice to put an axis label on the horizontal axis with > [text.parbox(width), text.valign.middle] > A problem for the above syntax: sometimes it is nice to > place just above the end of the y-axis a multiline title > (parbox) left justified to match the leftmost-extending > tick. I don't really get it. You do a title at the x-axis with [text.parbox(width), text.valign.middle]? BTW, you could throw away the middle, since the alignment of a title at the x-axis is strictly vertically, so changing the box reference point in the vertical direction doesn't have any influence. Back to the problem. When you do so for the x-axis, you can type text below the axis. Fine. How is this related to the title of the y axis? And why is what a problem? Sorry, could you tell it again ... I just don't get it ... > Anyway, you told me the right strategy for current problem: > I should just place the text where I want it. As I told. That's always a solution. Depending on you needs it might sometimes be just the most easiest solution ... ;-) André -- by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ ```
 Re[2]: [PyX-user] Re: graph question From: Alan G Isaac - 2005-09-22 19:17:46 ```>> But since we are speaking of axis titles let me add a new=20 >> problem to the mix: >> A pretty good match to the above syntax: sometimes it is=20 >> nice to put an axis label on the horizontal axis with=20 >> [text.parbox(width), text.valign.middle] >> A problem for the above syntax: sometimes it is nice to=20 >> place just above the end of the y-axis a multiline title=20 >> (parbox) left justified to match the leftmost-extending=20 >> tick.=20 On Thu, 22 Sep 2005, Andre Wobst apparently wrote:=20 > I don't really get it. You do a title at the x-axis with=20 > [text.parbox(width), text.valign.middle]? BTW, you could=20 > throw away the middle, since the alignment of a title at=20 > the x-axis is strictly vertically, so changing the box=20 > reference point in the vertical direction doesn't have any=20 > influence. Back to the problem. When you do so for the=20 > x-axis, you can type text below the axis. Fine. How is=20 > this related to the title of the y axis? And why is what=20 > a problem? Sorry, could you tell it again ... I just don't=20 > get it ...=20 Sorry to have been unclear. I am asking two new questions, and only in order to explore the new proposed syntax. 1. Sometimes it is nice to put an axis label on the=20 horizontal axis with [text.parbox(width), text.valign.middle] In other words, to place the text just after the end of=20 the horizontal and to center it vertically (especially if=20 it is multiple lines). I thought the new syntax would probably accommodate this. 2. sometimes it is nice to place just above the end of the=20 y-axis a multiline title (parbox) left justified to match=20 the leftmost-extending tick. I thought this would be a problem for the new syntax. To illustrate: MyYAxisTitle ticthree -| | ticktwo -| | tickone -| | ----------------------------- MyXAxisTitle To be clear: at the moment my needs are already being met. This is just exploring the syntax. Cheers, Alan Isaac ```
 Re: [PyX-user] Re: graph question From: Andre Wobst - 2005-09-23 04:59:20 ```Hi, On 22.09.05, Alan G Isaac wrote: > I am asking two new questions, > and only in order to explore the new proposed syntax. ... > To illustrate: > > MyYAxisTitle > ticthree -| > | > ticktwo -| > | > tickone -| > | > ----------------------------- MyXAxisTitle > > > To be clear: at the moment my needs are already being met. > This is just exploring the syntax. Ah, I got it. I somehow mixed up the two things before.Probably we'll do some redesign/modularization of the axis painter at some later point where we might just get those additional features "for free". In the mean (for PyX 0.9) a text decoration of the axis basepath is already a way to go. Beside doing it completely manually of course. Thanks for clearification! André -- by _ _ _ Dr. André Wobst / \ \ / ) wobsta@..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript and PDF figures (_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/ ```