How to use matplotlib to draw coordinate chart, radar chart and polar diagram
This article will explain in detail how to use matplotlib to draw coordinate maps, radar maps and polar maps. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Polar axis
When you call subplot () to create a subgraph, you can create a polar subgraph by setting projection='polar', and then call plot () to draw in the polar subgraph.
# Polar coordinates s = pd.Series (np.arange (20)) fig = plt.figure (figsize= (8Jing 4)) ax = plt.subplot (111111, projection = 'polar') ax.plot (s, linestyle =' -', marker ='., lw=2) # lw: lineweight
Click to add groups to get Python learning materials for free.
The information is in the group file waiting for you to pick it up.
Radar chart
# Radar chart-line chart / mapping of polar coordinates-plt.plot () plt.figure (figsize= (8je 4)) ax1= plt.subplot (111, projection='polar') ax1.set_title ('spot fish') # create title ax1.set_rlim (0Magol 12) # create data data1 = np.random.randint (1m 10m 10) data2 = np.random.randint (1m 10m 10) data3 = np.random.randint (1m 10m 10) theta=np.arange (0min 2m p. Pi) 2*np.pi/10) # draw radar line ax1.plot (theta,data1,'.--',label='data1') ax1.fill (theta,data1,alpha=0.2) ax1.plot (theta,data2,'.--',label='data2') ax1.fill (theta,data2,alpha=0.2) ax1.plot (theta,data3,'.--',label='data3') ax1.fill (theta,data3,alpha=0.2)
Polar chart-column chart of polar coordinates
# Polar chart-histogram of polar coordinates plt.figure (figsize= (8pr 4)) ax1= plt.subplot (111m, projection='polar') ax1.set_title ('spot fish') # create the title ax1.set_rlim (0jue 12) data = np.random.randint (1m 10pm 10) theta=np.arange (0theta,data,alpha=0.5 2pipp.pipp.pipp10) bar = ax1.bar (theta,data,alpha=0.5) for bar in zip (data) Bar): bar.set_facecolor (plt.cm.jet (rstroke 10.)) # sets the color
This is the end of the article on "how to use matplotlib to draw coordinate maps, radar maps, polar maps". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.