It really depends on what you want.
The problem with determining the circle in the data coordinates, when the aspect ratio is automatic, is that you can resize the shape (or its window), and the data scale will stretch beautifully. Unfortunately, this also means that your circle is no longer a circle, but an ellipse.
There are several ways to solve this problem. First and foremost, you can fix the aspect ratio, and then put the circle on the graph in the data coordinates:
import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = plt.axes() ax.set_aspect(1) theta = np.linspace(-np.pi, np.pi, 200) plt.plot(np.sin(theta), np.cos(theta)) plt.show()

In this case, you can scale and pan, as usual, but the shape will always be around.
If you just want to place a circle on the shape, regardless of the data coordinates, so that panning and zooming of the axes does not affect the position and enlargement of the circle, then you could do something like:
import matplotlib.patches as mpatches import matplotlib.pyplot as plt import numpy as np fig = plt.figure() ax = plt.axes() patch = mpatches.Circle((325, 245), 180, alpha=0.5, transform=None) fig.artists.append(patch) plt.show()

This is a pretty advanced mpl, but even so, I think it is readable.
NTN
pelson
source share