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。这也不能解决问题。)我试图调整这个答案,但效果不佳。我想它也必须是一个更容易的答案。Matplotlib 版本:matplotlib: 2.1.0
解决方案
推荐阅读
- ios - 无法将“__NSArray0”类型的值转换为“NSDictionary”
- python - 无法在 cmd 中执行带有 .py 扩展名的 python 脚本
- c# - HttpClient GetAsync 与 URL 中的哈希
- javascript - 异步/等待无法在 javascript 中进行 fetch API 调用
- c# - 需要帮助了解使用 LINQ Join 和 HashSet 的意外行为
- sql - 协助 SQL Server SELECT 查询
- php - 如何在sql中使用超过2个外键显示数据?
- awk - 将 file1 的 id 替换为 file2 的 id
- c++ - CMake - 来自 find_path 的错误 _INCLUDE_DIR 和来自 find_library 的错误 _LIB_DIR
- python - 如何像 R 语言一样在热图单元格上添加十字(X)?