2011-09-30 158 views
0

我試圖在笛卡爾座標中插入正常x vs y圖內的極座標圖。我知道插圖可以通過pylab.axes獲得,如example所示。但我不知道如何指定這是一個極地情節,可能沒有任何網格。歡迎任何幫助Matplotlib插入極座標圖

回答

3

在這裏你有一個工作的例子。
主要的一點是爲第二個數字指定一個新的,更小的軸

import numpy as np 
from matplotlib import pyplot as plt 
from scipy import randn, convolve 

#data 
t = np.arange(0.0, 20.0, 0.001) 
r = np.exp(-t[:1000]/0.05)  
x = randn(len(t)) 
s = convolve(x,r)[:len(x)]*0.001 
theta = 2 * np.pi * t 
# 
fig = plt.figure(figsize=(7, 6)) 
#main 
plt.plot(t, s) 
plt.axis([0, 1, np.amin(s), 2.5*np.amax(s)]) 
plt.xlabel('xlabel') 
plt.ylabel('ylabel') 
#polar 
ax = fig.add_axes([0.2, 0.47, 0.30, 0.40], polar=True, axisbg='yellow') 
ax.plot(theta, t, color='blue', lw=3) 
ax.set_rmax(1.0) 
plt.grid(True) 

plt.show()  

enter image description here

+0

非常感謝你簡單明瞭:-) –

+0

@NicolaVianello如果答案是非常有用的,然後投上一票。你有0%的接受率... – joaquin

+0

@NicolaVianello我清理了一些我組裝得太快的代碼。現在我覺得更簡單 – joaquin