[Matplotlib-users] Autoscaling after adding patches (and annotations)
Elan Ernest
elch.rz at ruetz-online.de
Fri Mar 22 09:48:15 EDT 2019
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
>
>
More information about the Matplotlib-users
mailing list