'Straight line does not touches in polar plot matplotlib
I'm doing a polar plot in matplotlib and I want to include a straight line that divides the circle in two. I have (removing the frames and the grids)
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)
If you see my attached image, the lines do not touch at the center. Is there any way to make them coincide at zero? (Surprisingly, I can use in radarr negative starting values like -0.7. This don't solves the problem either.) I have tried to adapt this answer but it does not work well. I suppose it has to be a more easier answer also. Matplotlib ver: matplotlib: 2.1.0
Solution 1:[1]
Try:
ax.set_ylim(radarr.min(), radarr.max())
or specify a suitable range(the bottom limit and the top limit) by yourself,
such as:
ax.set_ylim(0., 1.47)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kyle Lee |

