直线不接触极坐标图 matplotlib

时间:2021-06-01 13:57:15

标签: python matplotlib

我正在 matplotlib 中绘制极坐标图,我想包含一条将圆一分为二的直线。我有(移除框架和网格)

ax = plt.subplot(projection='polar')
theta = [0.0, 2*np.pi/6, 4*np.pi/6, 6*np.pi/6, 8*np.pi/6, 10*np.pi/6]
thetarr = np.linspace(0,2.0*np.pi,100)
radarr = np.full(100, 1.0)

ax.plot(thetarr, radarr, linestyle='-', marker='', color='gray')
ax.plot(thetarr, radarr-0.4, linestyle='-', marker='', color='gray')
ax.plot(thetarr, radarr+0.4, linestyle='-', marker='', color='gray')
thetarr = np.full(50,5*np.pi/6)
radarr = np.linspace(0.0,1.4,50)
ax.plot(thetarr, radarr, linestyle='-', color='gray')
thetarr = np.full(50,11*np.pi/6)
ax.plot(thetarr, radarr, linestyle='-', color='gray')

plt.text(5*np.pi/6+0.02, 1.7, r'$J_{\theta}$', color='blue', fontsize=18)

ax.grid(False)
plt.yticks([0.4,0.85,1.3], ['-0.4','0','0.4'])
ax.set_rlabel_position(142)
theta = [0.0, 2*np.pi/6, 4*np.pi/6, 6*np.pi/6, 8*np.pi/6, 10*np.pi/6]
plt.xticks(theta, ['1', '2', '3', '4', '5', '6'], color='blue')
ax.get_xticklabels()[0].set_color("red")
ax.get_xticklabels()[3].set_color("red")
ax.spines['polar'].set_visible(False)

如果您看到我所附的图片,线条不会在中心接触。有没有办法让它们在零处重合? (令人惊讶的是,我可以在 radarr 中使用负起始值,例如 -0.7。这也不能解决问题。)我尝试调整 this answer,但效果不佳。我想它也必须是一个更简单的答案。 Matplotlib 版本:matplotlib: 2.1.0

enter image description here

0 个答案:

没有答案
相关问题