2015-05-19 126 views
0

说我有以下的极坐标图:如何设置轴限制在matplotlib plt.polar情节

a=-0.49+1j*1.14 
plt.polar([0,angle(x)],[0,abs(x)],linewidth=5) 

matplotlib polar plot

而且我想调整径向限制以0比2 。

这样做的最好方法是什么?

请注意,我特别提到plt.polar()方法(与在类似问题中常见的常用图中使用polar=True参数相反)。

这似乎是工作,除非我从控制台(Spyder的,Win7的)策划:

>>> ax=plt.gca() 
>>> ax.set_rlim(0,2) 

回答

0

您可以只使用传统方法

import matplotlib.pyplot as plt 
import numpy as np 

x = np.arange(-180.0,190.0,10) 
theta = (np.pi/180.0)*x # in radians 

offset = 2.0 

R1 = [-0.358,-0.483,-0.479,-0.346,-0.121,0.137,0.358,0.483,0.479,0.346,0.121,\ 
-0.137,-0.358,-0.483,-0.479,-0.346,-0.121,0.137,0.358,0.483,0.479,0.346,0.121,\ 
-0.137,-0.358,-0.483,-0.479,-0.346,-0.121,0.137,0.358,0.483,0.479,0.346,0.121,\ 
-0.137,-0.358] 

fig1 = plt.figure() 
ax1 = fig1.add_axes([0.1,0.1,0.8,0.8],polar=True) 
ax1.set_ylim(-2,2) 
ax1.set_yticks(np.arange(-2,2,0.5)) 
ax1.plot(theta,R1,lw=2.5) 
plt.show() 

enter image description here