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),
> 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.