You may use offsetbox module.

Here is an complete example. Note that the circle always has a size of
25 point  and also is draggable,

Regards,

-JJ


import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import CirclePolygon, Circle

x = np.arange(0, 10, 0.1)
y = np.exp(-x/2.) * np.sin(2*np.pi*x)

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y, 'ro-', zorder=0)
ax.set_xlim(0, 10)
ax.set_ylim(-1, 1)

# I want this circle to appear as a circle
from matplotlib.offsetbox import DrawingArea, AnnotationBbox,
DraggableAnnotation
circle_radius = 25 # in points

da = DrawingArea(width=2*circle_radius, height=2*circle_radius,
                 xdescent=circle_radius, ydescent=circle_radius, clip=False)

circle = Circle((0.,0.), radius=circle_radius, zorder=1, alpha=0.5)
da.add_artist(circle)

an1 = AnnotationBbox(da,
                     xy=(7.5, 0.0), xycoords='data',
                     frameon=False, pad=0.,
                     annotation_clip=False,
                     box_alignment=(0.5, 0.5),
                     )


ax.add_artist(an1)

class DraggableAnn(DraggableAnnotation):
    def finalize_offset(self):
        loc_in_canvas = self.annotation.xytext
        self.annotation.textcoords = "data"
        pos_data =
self.annotation.axes.transData.inverted().transform_point(loc_in_canvas)
        self.annotation.xytext = tuple(pos_data)


drag1 = DraggableAnn(an1, use_blit=False)


plt.show()


On Wed, Mar 9, 2011 at 11:15 PM, Mads Ipsen <madsip...@gmail.com> wrote:
> I want the blue circle to appear as a circle with a 1:1 aspect ratio, making
> it look like a circle and not an ellipse. Just like the scale free circles
> making up the curve of the damped oscillationsn also shown in the plot.
>
> Preferably, the circle should also be scale free making it have the same
> size no-matter how much the plot has been zoomed.
>
>

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to