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()
Yes, that doesn't work. It just autoscales to a tiny portion of the data.
In my example, I generate the xy coordinates for the centers of hexagons
that tile a square area. The code adds the hexagons using add_artist.
Also, the centers of the hexagons are annotated. Neither of these
operations causes the axes to scale correctly. If I add a step to plot the
centers of the hexagons, using e.g., scatter, then the axes are scaled
correctly.
For now, I'm just adding the scatter plot with alpha=0 to get the scaling
correct.
But I still don't know a less klugey way to do it.
···
On Fri, Mar 22, 2019 at 12:43 AM Juan Nunez-Iglesias <jni.soma at gmail.com> wrote:
What's an
easy way to get the axes to scale correctly in this example?
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 Matplotlib-users Info Page
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
> Matplotlib-users Info Page
>
>
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org Matplotlib-users Info Page