From: Francisco Borges <f.borges@ru...>  20050913 13:25:09

Sorry for the delay answering... =BB On Thu, Sep 08, 2005 at 05:42PM +0200, Joerg Lehmann wrote: > Hello Francisco, >=20 > On 08.09.05, Francisco Borges wrote: > > 2. Not knowing very well how to perform "fills", I've been doing this= : > >=20 > > dt =3D g.plot(graph.data.function("y(x) =3D exp(x)",min=3DMIN, max=3D= MAX ))#, min=3D0, max=3D2*pi)) > > g.finish() > > g.fill(dt.path, Color) >=20 >=20 > Why don't you just pass deco.filled to graph.style.line: >=20 > g.plot(graph.data.function("y(x) =3D exp(x)", min=3DMIN, max=3DMAX), > [graph.style.line([deco.filled])]) >=20 Thanks, this helped a lot.=20 I hadn't realized that it could be this easy to fill in a graph. Though n= ow that I think of it, there is no reason not to do it. I would recommend you guys to add some silly example of graph filling to = the PyX graph examples. All examples there with filling involve rather complicated path manipulation. Thanks again, Francisco 
From: Francisco Borges <f.borges@ru...>  20050908 13:47:18

Hello, I've been doing lot's of figures and though I have sort of managed to solve this two problems, still I would like to ask if there is an easier way out: 1. Often I've connected a plotted point with a box of text. Not having a box present at the plotted point, I normally insert one like this: x0, y0 = g.pos(pto[0], pto[1]) T1 = g.text(x0, y0, " ", text_stl) Is there an easier way to get an "empty box"? 2. Not knowing very well how to perform "fills", I've been doing this: dt = g.plot(graph.data.function("y(x) = exp(x)",min=MIN, max=MAX ))#, min=0, max=2*pi)) g.finish() g.fill(dt.path, Color) My problem is that more than once I want to plot other stuff than the filling would cover somehow. I mean I can fix the geometry with dolayout and still plot, but then I can't yet fill using the plotted function. I've been solving this by using two graphs and inserting one into the other. Is there another way to do this? Cheers, Francisco 
From: Michael J Gruber <michaeljgruber+<pyx@fa...>  20050908 14:01:03

Francisco Borges venit, vidit, dixit 09/08/05 15:47: > 1. Often I've connected a plotted point with a box of text. Not > having a box present at the plotted point, I normally insert one like > this: > > x0, y0 = g.pos(pto[0], pto[1]) T1 = g.text(x0, y0, " ", text_stl) > > Is there an easier way to get an "empty box"? I'm afraid I don't understand what you are trying to achieve with the empty box. Do have a more complete example? > 2. Not knowing very well how to perform "fills", I've been doing > this: > > dt = g.plot(graph.data.function("y(x) = exp(x)",min=MIN, max=MAX > ))#, min=0, max=2*pi)) g.finish() g.fill(dt.path, Color) > > My problem is that more than once I want to plot other stuff than the > filling would cover somehow. I mean I can fix the geometry with > dolayout and still plot, but then I can't yet fill using the plotted > function. use dodata() instead of dolayout(), and the plot path will be available. Cheers, Michael 
From: Francisco Borges <f.borges@ru...>  20050908 14:30:06
Attachments:
duality_gap.py

=BB On Thu, Sep 08, 2005 at 04:00PM +0200, Michael J Gruber wrote: > I'm afraid I don't understand what you are trying to achieve with the > empty box. Do have a more complete example? I want arrows pointing to specific positions on the graph (where I already have something plotted). I've attached a file with a real example. Check the lines with box1 =3D g.text(x0, y0, " ") > > My problem is that more than once I want to plot other stuff than the > > filling would cover somehow. I mean I can fix the geometry with > > dolayout and still plot, but then I can't yet fill using the plotted > > function. > > use dodata() instead of dolayout(), and the plot path will be available. I had tried that, but the point is that after the filling I still want to plot things (because plotting them before filling would make the filled area cover partially the plotted lines. The attached file illustrates this a bit, the "primal solution" line would have been half covered by the filling. Francisco 
From: Joerg Lehmann <joergl@us...>  20050908 15:42:42

Hello Francisco, On 08.09.05, Francisco Borges wrote: > 2. Not knowing very well how to perform "fills", I've been doing this: > > dt = g.plot(graph.data.function("y(x) = exp(x)",min=MIN, max=MAX ))#, min=0, max=2*pi)) > g.finish() > g.fill(dt.path, Color) Why don't you just pass deco.filled to graph.style.line: g.plot(graph.data.function("y(x) = exp(x)", min=MIN, max=MAX), [graph.style.line([deco.filled])]) HTH, Jörg 
From: Francisco Borges <f.borges@ru...>  20050913 13:25:09

Sorry for the delay answering... =BB On Thu, Sep 08, 2005 at 05:42PM +0200, Joerg Lehmann wrote: > Hello Francisco, >=20 > On 08.09.05, Francisco Borges wrote: > > 2. Not knowing very well how to perform "fills", I've been doing this= : > >=20 > > dt =3D g.plot(graph.data.function("y(x) =3D exp(x)",min=3DMIN, max=3D= MAX ))#, min=3D0, max=3D2*pi)) > > g.finish() > > g.fill(dt.path, Color) >=20 >=20 > Why don't you just pass deco.filled to graph.style.line: >=20 > g.plot(graph.data.function("y(x) =3D exp(x)", min=3DMIN, max=3DMAX), > [graph.style.line([deco.filled])]) >=20 Thanks, this helped a lot.=20 I hadn't realized that it could be this easy to fill in a graph. Though n= ow that I think of it, there is no reason not to do it. I would recommend you guys to add some silly example of graph filling to = the PyX graph examples. All examples there with filling involve rather complicated path manipulation. Thanks again, Francisco 
From: Andre Wobst <wobsta@us...>  20050914 06:04:37

On 13.09.05, Francisco Borges wrote: > I would recommend you guys to add some silly example of graph filling to the > PyX graph examples. All examples there with filling involve rather > complicated path manipulation. But isn't your filling just from the starting and end point of your path a very uncommon task? And once you can stroke something you can also fill it. We might  overall  work on the decorator description, right ... since it is a general concept in PyX and it might not be that easy to gasp at the first ... 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/ 
From: Thomas Pohl <thomas.pohl@in...>  20051010 12:24:47

Hi, I think I have a similar question/problem/feature request concerning the filling of graphs. Please have a look at the commented example below. The graph contains several plots which are filled down to the baseline. In order to achieve this, I load the columns seperately using graph.data.file, store them in lists, and manipulate these lists before drawing to have them filled to the baseline. I don't think that this type of graph is so uncommon, so a dedicated graph style would be helpful for many users I'd guess. Can anyone think of an easier way to do the same task? Thanks a lot, Tom  from pyx import * columnName = ('a', 'b', 'c', 'd') g = graph.graphxy(width=8, y=graph.axis.lin(min=0.0, max=35.0)) # read column 't' from file 'fill_example.dat' and store it in dataX dataX = graph.data.file('fill_example.dat', v='t').getcolumnpointsindex('v') # duplicate first and last entry to extend the filling to the baseline dataX.insert(0, dataX[0]) dataX.append(dataX[1]) for i in range(len(columnName)): # read column from file and store in dataY dataY = graph.data.file('fill_example.dat', v=columnName[i]).getcolumnpointsindex('v') # set zero values for duplicated x values dataY.insert(0, 0) dataY.append(0) # plot and fill column data with different colors g.plot(graph.data.list(zip(dataX, dataY), x=1, y=2), [graph.style.line([deco.filled, color.palette.RedBlue.getcolor(float(i)/(len(columnName)1))])]) # draw background and data before drawing axis to avoid overwriting g.dobackground() g.dodata() g.writeEPSfile('fill_example') """ # "fill_example.dat" look like this: # t a b c d 0 35 23 16 2 1 35 25 11 8 2 35 29 12 7 3 35 28 17 9 4 35 24 19 5 """   Thomas Pohl, Lehrstuhl fuer Informatik X (Systemsimulation), Universitaet Erlangen, Cauerstr. 6, D91058 Erlangen, Germany phone: +49(0)9131 8528687 fax: +49(0)9131 8528928 url: http://www10.informatik.unierlangen.de/~pohlt/ 
From: Andre Wobst <wobsta@us...>  20050909 13:36:12

Hi Francisco, sorry for my late response. I'm really short in time at the moment. On 08.09.05, Francisco Borges wrote: > 1. Often I've connected a plotted point with a box of text. Not having a > box present at the plotted point, I normally insert one like this: > > x0, y0 = g.pos(pto[0], pto[1]) > T1 = g.text(x0, y0, " ", text_stl) > > Is there an easier way to get an "empty box"? Yes. You can use the box module to create rectangular boxes. (There is a rect class in there. It should fill the bill and help you constructing connectors. I should note, that I'm planing to discuss the whole box system from scratch again, but overall we want to keep the functionality we have (and add a lot of things). At the moment boxes are a shabby thing in PyX. (And that's my fault, since for the moment I just need them internally and never really thought about the full picture.) > 2. Not knowing very well how to perform "fills", I've been doing this: > > dt = g.plot(graph.data.function("y(x) = exp(x)",min=MIN, max=MAX ))#, min=0, max=2*pi)) > g.finish() > g.fill(dt.path, Color) > > My problem is that more than once I want to plot other stuff than the > filling would cover somehow. I mean I can fix the geometry with dolayout > and still plot, but then I can't yet fill using the plotted function. > > I've been solving this by using two graphs and inserting one into the > other. Is there another way to do this? First, the example you sent, goes into an assert. You may have commented out this, and this works, since you're not changing the axes ranges. But its not the proper way of doing things. The proper way to solve you original issue (at least as far as I understand it), would be to understand, that you can insert things below the data and on top of it. To insert something below, you can do it before g.data is called and to do it afterwards, insert something after that. Note, that you can insert canvas instances as well. So I think that's the way to go for you. Suppose you want to stroke something now on the graph, but is should occur after the data has been inserted. So just stroke it on a canvas, then add further plot commands etc. Then finish the graph (or at least call dodata). And then insert the canvas into the graph. All stuff in the canvas will then be on top of the data, although you create the material before. You should not need a second, equal, graph instance. Beside that I've reworked some graph domethoddependancies. By that we can now also add stuff to the graph by the plot method after we already finished its layout. This will not alter the axes ranges anymore, but it's an interesting feature for various occations. So, yes, we already do have various interesting things in the quere for 0.9 ... 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/ 
From: Francisco Borges <f.borges@ru...>  20050913 13:34:49

=BB On Fri, Sep 09, 2005 at 03:35PM +0200, Andre Wobst wrote: > sorry for my late response. I'm really short in time at the moment. Now, my answer comes at an even greater delay. :) > On 08.09.05, Francisco Borges wrote: > > 1. Often I've connected a plotted point with a box of text. Not havin= g a > > box present at the plotted point, I normally insert one like this: > >=20 > > x0, y0 =3D g.pos(pto[0], pto[1]) > > T1 =3D g.text(x0, y0, " ", text_stl) > >=20 > > Is there an easier way to get an "empty box"? >=20 > Yes. You can use the box module to create rectangular boxes. (There is > a rect class in there. It should fill the bill and help you > constructing connectors. >=20 > I should note, that I'm planing to discuss the whole box system from > scratch again, but overall we want to keep the functionality we have > (and add a lot of things). At the moment boxes are a shabby thing in > PyX. (And that's my fault, since for the moment I just need them > internally and never really thought about the full picture.) Yes, I had seen the box module but it's documentation is a bit sparse and from comments in the documentation it looked like something that would change sooner or later. > The proper way to solve you original issue (at least as far as I > understand it), would be to understand, that you can insert things > below the data and on top of it. To insert something below, you can do > it before g.data is called and to do it afterwards, insert something > after that. Note, that you can insert canvas instances as well. So I > think that's the way to go for you. Suppose you want to stroke > something now on the graph, but is should occur after the data has > been inserted. So just stroke it on a canvas, then add further plot > commands etc. Then finish the graph (or at least call dodata). And > then insert the canvas into the graph. All stuff in the canvas will > then be on top of the data, although you create the material before. I'm not sure I got your point here :) Anyway I did get that in the future I'll be able to plot after finishing = the layout of the graph and that was the showstopper for me. Cheers, Francisco 
From: Andre Wobst <wobsta@us...>  20050914 06:09:48

Hi, On 13.09.05, Francisco Borges wrote: > > The proper way to solve you original issue (at least as far as I > > understand it), would be to understand, that you can insert things > > below the data and on top of it. To insert something below, you can do > > it before g.data is called and to do it afterwards, insert something > > after that. Note, that you can insert canvas instances as well. So I > > think that's the way to go for you. Suppose you want to stroke > > something now on the graph, but is should occur after the data has > > been inserted. So just stroke it on a canvas, then add further plot > > commands etc. Then finish the graph (or at least call dodata). And > > then insert the canvas into the graph. All stuff in the canvas will > > then be on top of the data, although you create the material before. > > I'm not sure I got your point here :) So let me post a simple example of what I wanted to describe :): from pyx import * c = canvas.canvas() c1 = canvas.canvas() c2 = canvas.canvas() c1.stroke(path.line(0, 0, 1, 0), [color.rgb.red]) c2.stroke(path.line(1, 0, 2, 0), [color.rgb.green]) c.insert(c1) # insert below the text c.text(0, 0, "Hello, world!", [text.vshift.mathaxis]) c.insert(c2) # insert abobe the text c.writeEPSfile("insert") > Anyway I did get that in the future I'll be able to plot after finishing the > layout of the graph and that was the showstopper for me. Right. We'll have this in the future ... 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/ 