簡體   English   中英

如何創建這兩個獨立極坐標圖的圖形?

[英]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()

這將它繪制在同一圖表上,我需要它是兩個單獨圖形的圖形。

您需要以下內容: 121表示首先繪制1x2子圖網格, 122表示該1x2子圖網格上的第二個繪圖。

ax1 = plt.subplot(121, projection='polar')
ax1.plot(Theta.flatten(), STheta.flatten())
ax2 = plt.subplot(122, 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM