I want to draw Circle on my plot. For this purpose I decided to use patch.Circle class from matplotlib. Cirlce object uses radius argument to set a radius of a circle, but if the axes ratio is not 1 (see my plot), how to draw circle with right proportions? My code for drawing circle is:
rect = patches.Circle(xy=(9, yaxes),radius= 2, linewidth=3, edgecolor='r', facecolor='red',alpha=0.5)
ax.add_patch(rect)
yaxes is equal 206 in this example (because I wanted to draw it upper left coner). Here is a picture I got using this code:
But I want something like this:
CodePudding user response:
The issue seems to be that your X (passed to xy=
) is not always the same as your Y, thus the oval instead of a perfect circle.
CodePudding user response:
Some remarks about drawing the ellipse:
- this will only work for linear coordinates, not e.g. for logscale or polar coordinates
- the code supposes nor the axis limits nor the axis position will change afterwards, as these will distort the aspect ratio