Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Dani Marti <daniel.marti@up...>  20050527 17:44:25

Hi all, I am using PyX to represent a vector field in 2D. I start from a data file with four columns, x y dx dy . . . . . . . . From this data I'd like to plot a vector with components (dx,dy) at point (x,y). This is matlab's "quiver" function convention (I should stick to this). I store each row of the data file as an element of a list, and then use it as the input for graph.data.list: g.plot(graph.data.list(list_vectors, x = 1, y = 2, size = 3, angle = 4), [graph.style.arrow()]) Everything is fine, except for two things:  the huge arrow heads (the longer the vector, the bigger the head). I'd like to have always the same size for the heads (preferably small, just to see to what direction the vector points to).  It is not the tail of the vector which is at (x,y), but the midpoint of it, and this is not what I want. Does anyone have any idea of how to solve this in a simple way? Is there a more convenient or simpler way of plotting 2D vector fields with PyX? By the way, could someone show an example of arrowattr=[], please? I didn't manage to find examples in the documentation. Thanks a lot in advance, Dani 
From: Joerg Lehmann <joergl@us...>  20050528 09:18:45

Hi Dani, On 27.05.05, Dani Marti wrote: > I am using PyX to represent a vector field in 2D. > I start from a data file with four columns, > > x y dx dy > . . . . > . . . . > > >From this data I'd like to plot a vector with components (dx,dy) > at point (x,y). This is matlab's "quiver" function convention (I should > stick to this). I store each row of the data file as an element of a > list, and then use it as the input for graph.data.list: > > g.plot(graph.data.list(list_vectors, x = 1, y = 2, size = 3, angle = 4), > [graph.style.arrow()]) > > Everything is fine, except for two things: > >  the huge arrow heads (the longer the vector, the bigger the > head). I'd like to have always the same size for the heads > (preferably small, just to see to what direction the vector > points to). I just had a look in the code and saw that this is indeed the case, though I'm not sure why. >  It is not the tail of the vector which is at (x,y), but the > midpoint of it, and this is not what I want. Does > anyone have any idea of how to solve this in a simple way? You could just define a new style deriving from the arrow style and replace the drawpoint function to do what you want. Just have a look at the code (in pyx/graph/style.py), it's pretty straightforward. > Is there a more convenient or simpler way of plotting 2D vector > fields with PyX? > > By the way, could someone show an example of arrowattr=[], please? I > didn't manage to find examples in the documentation. You could for instance use arrowattrs=[color.rgb.red] to get red arrow heads, etc. HTH, Jörg 
From: Simon Burton <simon@ar...>  20060813 05:43:58

On Sat, 28 May 2005 11:18:36 +0200 Joerg Lehmann <joergl@...> wrote: > You could just define a new style deriving from the arrow style and > replace the drawpoint function to do what you want. Just have a look at > the code (in pyx/graph/style.py), it's pretty straightforward. > Here it is: class arrow(graph.style.arrow): def drawpoint(self, privatedata, sharedata, graph, point): if privatedata.lineattrs is not None and privatedata.arrowattrs is not None and sharedata.vposvalid: linelength_pt = unit.topt(self.linelength) x_pt, y_pt = graph.vpos_pt(*sharedata.vpos) try: angle = point["angle"] + 0.0 size = point["size"] + 0.0 except: pass else: if point["size"] > self.epsilon: dx = math.cos(angle*math.pi/180) dy = math.sin(angle*math.pi/180) x1 = x_pt #0.5*dx*linelength_pt*size y1 = y_pt #0.5*dy*linelength_pt*size x2 = x_pt+1.0*dx*linelength_pt*size y2 = y_pt+1.0*dy*linelength_pt*size privatedata.arrowcanvas.stroke(path.line_pt(x1, y1, x2, y2), privatedata.lineattrs + [deco.earrow(privatedata.arrowattrs, size=self.arrowsize*size)]) Can I suggest that these numbers (0.5 and +0.5, which I changed to 0.0 and 1.0) become parameters ? Simon.  Simon Burton, B.Sc. Licensed PO Box 8066 ANU Canberra 2601 Australia Ph. 61 02 6249 6940 http://arrowtheory.com 
From: Joerg Lehmann <joergl@us...>  20060813 07:27:20

Hello, On 13.08.06, Simon Burton wrote: [ snip ] > x1 = x_pt #0.5*dx*linelength_pt*size > y1 = y_pt #0.5*dy*linelength_pt*size > x2 = x_pt+1.0*dx*linelength_pt*size > y2 = y_pt+1.0*dy*linelength_pt*size > privatedata.arrowcanvas.stroke(path.line_pt(x1, y1, x2, y2), privatedata.lineattrs + > [deco.earrow(privatedata.arrowattrs, size=self.arrowsize*size)]) > > Can I suggest that these numbers (0.5 and +0.5, which I changed to 0.0 and 1.0) > become parameters ? Seems reasonable. If you'd have a good name for the new parameter, it would be even easier to add this feature. Jörg 
From: Simon Burton <simon@ar...>  20060814 14:15:27

On Sun, 13 Aug 2006 09:27:07 +0200 Joerg Lehmann <joergl@...> wrote: > > > Can I suggest that these numbers (0.5 and +0.5, which I changed to 0.0 and 1.0) > > become parameters ? > > Seems reasonable. If you'd have a good name for the new parameter, it > would be even easier to add this feature. How about "align" ? Simon.  Simon Burton, B.Sc. Licensed PO Box 8066 ANU Canberra 2601 Australia Ph. 61 02 6249 6940 http://arrowtheory.com 
From: Andre Wobst <wobsta@us...>  20060816 08:43:01

Hi, On 15.08.06, Simon Burton wrote: > > > Can I suggest that these numbers (0.5 and +0.5, which I changed to 0.0 and 1.0) > > > become parameters ? > > > > Seems reasonable. If you'd have a good name for the new parameter, it > > would be even easier to add this feature. > > How about "align" ? I see some similarities to autohistogrampointpos=0.5 of the histogram style ... and hence suggest to call it arrowpos. I think this is a good name and went ahead already and added it to the trunk ... :) 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/ 
Sign up for the SourceForge newsletter:
No, thanks