![](/img/trans.png)
[英]How do I get smooth gridlines in cartopy polar stereographic plots with matplotlib?
[英]How do I create a figure of these two separate polar plots?
我試圖在同一個圖上創建兩個單獨的圖作為子圖。 兩塊地塊都是極地的。 我的嘗試使他們在同一個圖上繪圖。
def GenerateTrigonometryTable(x): #Define Function
A = np.arange (0,360,x)
B = np.sin(A*np.pi/180)
C = np.cos(A*np.pi/180)
table = np.dstack(([A],[B],[C]))
return table
Theta = (GenerateTrigonometryTable(5)[:,:,0])
STheta = (GenerateTrigonometryTable(5)[:,:,1])
CTheta = (GenerateTrigonometryTable(5)[:,:,2])
ax1 = plt.subplot(111, projection='polar')
ax1.plot(Theta.flatten(), STheta.flatten())
ax2 = plt.subplot(111, projection='polar')
ax2.plot(Theta.flatten(), CTheta.flatten())
fig.show()
這將它繪制在同一圖表上,我需要它是兩個單獨圖形的圖形。
更面向對象的方法是:
fig = plt.figure()
ax1 = fig.add_subplot(121, projection='polar')
ax2 = fig.add_subplot(122, projection='polar')
ax1.plot(Theta.flatten(), STheta.flatten())
ax2.plot(Theta.flatten(), CTheta.flatten())
fig.show()
相當於Sheldore的答案,但展示了如何在matplotlib中表達數字,軸和圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.