From: John H. <jdh...@ac...> - 2005-01-20 20:13:18
|
>>>>> "Humufr" == Humufr <hu...@ya...> writes: Humufr> I understand your point but I think that to draw on object Humufr> inside a figure, using some relative coordinate are not Humufr> very convenient. You add to play with the data coordinates Humufr> and the figures coordinates. That can be useful for some Humufr> objects but very often some people would like to plot a Humufr> rectangle (or what do you want) with the data corrdinate Humufr> and it's very disturbing at the beginning the way that Humufr> patches is working. I don't know if I'm clear this time Humufr> (my english is very poor sometimes). Yes, apparently there is something of a language barrier -- my french is not so good either, sigh. But I just want to reiterate, you are not using relative coords for the rectangle in the example below. When you do the following, from pylab import * from matplotlib.patches import Rectangle ax = gca() p = Rectangle((1,1),3,3,fill=False) ax.add_patch(p) your rectangle is in *data coordinates* and it is where it should be (center at 1,1 and width=height=3). The problem is that your axis "view" limits are not set properly (if you use the pan and zoom features of the toolbar to move your view limits you'll see the rectangle where it should be. Only the plot commands (plot, scatter, etc,....) call autoscale_view to set the view limits (add_patch does not), so you need to set the axis limits yourself. axis([0,10,0,10]) In summary, the rectangle is being added in the right coordinate system (data coords) but the view limits are not automatically autoscaled unless you issue a plot command. I choose not to do autoscale every time a patch is added for performance reasons -- if you are savvy enough to call add_patch, I assume you are savvy enough to call set_xlim or set_ylim as appropriate for your data. JDH |