trace a rectangle

but if you use axis only without redefine gca limit that

    > don't work:

    > from pylab import * from matplotlib.patches import
    > Rectangle axis([0,10],[0,10]) ax = gca() p =
    > Rectangle((1,1),3,3,fill=False) ax.add_patch(p)

I think you screwed up the "axis" syntax. What you mean (I think) is:

    from pylab import *
    from matplotlib.patches import Rectangle
    axis([0,10,0,10])
    ax = gca()
    p = Rectangle((1,1),3,3,fill=False)
    ax.add_patch(p)
    show()

    > I understand that gca return an instance but perhaps that
    > will be a good idea if by default that will use the axis
    > of the courrant figure and not [0,1,0,1].

I'm a little confused here. gca returns the current axes (note axis
and axes are different commands and have different meanings). The
default axes is

2 >>> ax = gca()

3 >>> ax.get_position()
Out[3]: [0.125, 0.10999999999999999, 0.77500000000000002, 0.79000000000000004]

Can you clarify your meaning? axis set the view limits of the current
axes. The view limits are in data coordinates, and these are the same
limits that are controlled by xlim and ylim. axes sets the position
of the axes (the frame in which your plots are made) and these
coordinates are in figure coords -- 0,0 is lower left of the figure
and 1,1 is upper right.

JDH

John Hunter wrote:

"Humufr" == Humufr <humufr@...136...> writes:
           
   > but if you use axis only without redefine gca limit that
   > don't work:

   > from pylab import * from matplotlib.patches import
   > Rectangle axis([0,10],[0,10]) ax = gca() p =
   > Rectangle((1,1),3,3,fill=False) ax.add_patch(p)

I think you screwed up the "axis" syntax. What you mean (I think) is:

   from pylab import *
   from matplotlib.patches import Rectangle
   axis([0,10,0,10])
   ax = gca()
   p = Rectangle((1,1),3,3,fill=False)
   ax.add_patch(p)
   show()

yes sorry I did mistake in my mail but the result is the same. I can't draw the rectangle where I want. To do this I had to set the xlim and ylim manually.

   > I understand that gca return an instance but perhaps that
   > will be a good idea if by default that will use the axis
   > of the courrant figure and not [0,1,0,1].

I'm a little confused here. gca returns the current axes (note axis
and axes are different commands and have different meanings). The
default axes is

2 >>> ax = gca()

3 >>> ax.get_position()
Out[3]: [0.125, 0.10999999999999999, 0.77500000000000002, 0.79000000000000004]

Can you clarify your meaning? axis set the view limits of the current
axes. The view limits are in data coordinates, and these are the same
limits that are controlled by xlim and ylim. axes sets the position
of the axes (the frame in which your plots are made) and these
coordinates are in figure coords -- 0,0 is lower left of the figure
and 1,1 is upper right.

I understand your point but I think that to draw on object inside a figure, using some relative coordinate are not very convenient. You add to play with the data coordinates and the figures coordinates. That can be useful for some objects but very often some people would like to plot a rectangle (or what do you want) with the data corrdinate and it's very disturbing at the beginning the way that patches is working.
I don't know if I'm clear this time (my english is very poor sometimes).

Thanks,

    Nicolas