Skip to content Skip to sidebar Skip to footer

How To Make Smooth Circles On Basemap Projections In Matplotlib By Python

I'm not advanced user of Python, but due to my scientific work I got tasks to plot some graphs with Matplotlib. Now I have to draw smooth-deformed according to the basemap project

Solution 1:

The function plt.Circle() does not allow to specify the number of vertexes to plot. So, you need to write up your own code. Here is my code that you may try:

# Plot circle with 36 vertexes
phi = np.linspace(0, 2.*np.pi, 36)  #36 points
r = np.radians(40)
x = np.radians(35) + r*np.cos(phi)
y = np.radians(30) + r*np.sin(phi)
ax.plot(x, y, color="g")

Use my code in place of yours 2 lines:

circle1 = plt.Circle((np.radians(35), np.radians(30)), np.radians(40), color='g', fill = False)  # Circle parameters
ax.add_artist(circle1)

The resulting image:

enter image description here

Post a Comment for "How To Make Smooth Circles On Basemap Projections In Matplotlib By Python"