ellipse in log-log

Dear list,

How is it possible to draw a nice ellipse in a log-log plot using patches.Ellipse ?
With matplotlib 0.91 I was able to to that using :
Ellipse((log10(100),log10(100)), width=100, height=100,alpha=0.5)

Now, it seems that something has changed in version 0.98 and I do not need to ad the log10
in Ellipse. However, instead of having a nice ellipse, I get a kind of patatoïd ?
See the example below.
How can I fix it ?

Thanks in advance,

yves

from numpy import *
import pylab as pt
from matplotlib.patches import Ellipse

ax = pt.gca()

e = Ellipse((100,100), width=100, height=100,alpha=0.5)
ax.add_artist(e)

pt.semilogx()
pt.semilogy()

pt.axis([1,1e3,1,1e3])

pt.show()

···

--
                                                 (o o)
--------------------------------------------oOO--(_)--OOo-------
  Yves Revaz
  Laboratory of Astrophysics EPFL
  Observatoire de Sauverny Tel : ++ 41 22 379 24 28
  51. Ch. des Maillettes Fax : ++ 41 22 379 22 05
  1290 Sauverny e-mail : Yves.Revaz@...2003...
  SWITZERLAND Web : http://www.lunix.ch/revaz/
----------------------------------------------------------------

In 0.98 ellipse is drawn using bezier curves, which do not scale correctly in log-scaled plots.

As an alternative, you can use a RegularPolygon with a high number of vertices (this is exactly what 0.91 did).

Mike

Yves Revaz wrote:

···

Dear list,

How is it possible to draw a nice ellipse in a log-log plot using patches.Ellipse ?
With matplotlib 0.91 I was able to to that using :
Ellipse((log10(100),log10(100)), width=100, height=100,alpha=0.5)

Now, it seems that something has changed in version 0.98 and I do not need to ad the log10
in Ellipse. However, instead of having a nice ellipse, I get a kind of patato�d ?
See the example below.
How can I fix it ?

Thanks in advance,

yves

from numpy import *
import pylab as pt
from matplotlib.patches import Ellipse

ax = pt.gca()

e = Ellipse((100,100), width=100, height=100,alpha=0.5)
ax.add_artist(e)

pt.semilogx()
pt.semilogy()

pt.axis([1,1e3,1,1e3])

pt.show()

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

Here is some example code which compares the polygonal ellipse with
the spline version to get you started if you decide to go with the
polygonal appromximation Michal suggest:

import numpy as npy
from matplotlib import patches
from pylab import figure, show

xcenter, ycenter = 0.38, 0.52
#xcenter, ycenter = 0., 0.
width, height = 1e-1, 3e-1
angle = -30

theta = npy.arange(0.0, 360.0, 1.0)*npy.pi/180.0
x = width/2. * npy.cos(theta)
y = height/2. * npy.sin(theta)

rtheta = angle*npy.pi/180.
R = npy.array([
    [npy.cos(rtheta), -npy.sin(rtheta)],
    [npy.sin(rtheta), npy.cos(rtheta)],
    ])

x, y = npy.dot(R, npy.array([x, y]))
x += xcenter
y += ycenter

fig = figure()
ax = fig.add_subplot(211, aspect='auto')
ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow',
linewidth=1, zorder=1)

e1 = patches.Arc((xcenter, ycenter), width, height,
             angle=angle, linewidth=2, fill=False, zorder=2)

ax.add_patch(e1)

ax = fig.add_subplot(212, aspect='equal')
ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1)
e2 = patches.Arc((xcenter, ycenter), width, height,
             angle=angle, linewidth=2, fill=False, zorder=2)

ax.add_patch(e2)

#fig.savefig('ellipse_compare.png')
fig.savefig('ellipse_compare')

show()

···

On Mon, Oct 6, 2008 at 7:15 AM, Michael Droettboom <mdroe@...86...> wrote:

In 0.98 ellipse is drawn using bezier curves, which do not scale
correctly in log-scaled plots.

As an alternative, you can use a RegularPolygon with a high number of
vertices (this is exactly what 0.91 did).