[Matplotlib-users] Autoscaling after adding patches (and annotations)

Neal Becker ndbecker2 at gmail.com
Fri Mar 22 10:38:10 EDT 2019


OK, using ax.add_patch() together with ax.autoscale_view() (after adding
all patches) gives the desired result.
Thanks!

On Fri, Mar 22, 2019 at 10:04 AM Elan Ernest <elch.rz at ruetz-online.de>
wrote:

> To add a patch to an axes use `ax.add_patch()`.
>
> If you have several patches, consider using a collection, as shown in
> https://matplotlib.org/gallery/shapes_and_collections/collections.html
> or
> https://matplotlib.org/gallery/shapes_and_collections/patch_collection.html
>
> Am 21.03.2019 um 15:44 schrieb Neal Becker:
> > In this code, I add polygons and text annotations.  The result is
> plotted on
> > axes scaled [0..1], not autoscaled to match the data.  If I add e.g., a
> > scatterplot of the polygon centers, the result in scaled fine.  What's an
> > easy way to get the axes to scale correctly in this example?
> >
> > for i, center in enumerate(centers):
> >      circle = mpl.patches.RegularPolygon ((center.real, center.imag), 6,
> 1,
> > fill=False, clip_on=False, linestyle='-', orientation=30*pi/180)
> >      ax.add_artist (circle)
> >      ax.annotate (beam_colors[i], xy=(center.real, center.imag),
> > textcoords='offset points', xytext=(-3,3))
> > plt.show()
> >
> >
> > _______________________________________________
> > Matplotlib-users mailing list
> > Matplotlib-users at python.org
> > https://mail.python.org/mailman/listinfo/matplotlib-users
> >
> >
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190322/926ea26e/attachment.html>


More information about the Matplotlib-users mailing list