Note

Go to the endto download the full example code.

Scatter plot on polar axis#

Size increases radially in this example and color increases with angle(just to verify the symbols are being scattered correctly).

importmatplotlib.pyplotaspltimportnumpyasnp# Fixing random state for reproducibilitynp.random.seed(19680801)# Compute areas and colorsN=150r=2*np.random.rand(N)theta=2*np.pi*np.random.rand(N)area=200*r**2colors=thetafig=plt.figure()ax=fig.add_subplot(projection='polar')c=ax.scatter(theta,r,c=colors,s=area,cmap='hsv',alpha=0.75)
polar scatter

Scatter plot on polar axis, with offset origin#

The main difference with the previous plot is the configuration of the originradius, producing an annulus. Additionally, the theta zero location is set torotate the plot.

fig=plt.figure()ax=fig.add_subplot(projection='polar')c=ax.scatter(theta,r,c=colors,s=area,cmap='hsv',alpha=0.75)ax.set_rorigin(-2.5)ax.set_theta_zero_location('W',offset=10)
polar scatter

Scatter plot on polar axis confined to a sector#

The main difference with the previous plots is the configuration of thetheta start and end limits, producing a sector instead of a full circle.

fig=plt.figure()ax=fig.add_subplot(projection='polar')c=ax.scatter(theta,r,c=colors,s=area,cmap='hsv',alpha=0.75)ax.set_thetamin(45)ax.set_thetamax(135)plt.show()
polar scatter

Tags:plot-type: polarplot-type: scatterlevel: beginner

Total running time of the script: (0 minutes 1.930 seconds)

Gallery generated by Sphinx-Gallery