[英]Polar plot in Matplotlib not centered
For some reasons, when I try to plot (theta = 0, r = 0)
using the following code : 由于某些原因,当我尝试使用以下代码绘制
(theta = 0, r = 0)
:
import matplotlib.pyplot as plt
plt.polar(0, 0, marker='x')
plt.show()
The point is not centered : 该点未居中:
I was able to reproduce this error multiple times on my computer and on Repl.it : Link 我能够在计算机和Repl.it上多次重现此错误: 链接
So, how can I center the polar plot, so that the x
shows in the center of it ? 那么,如何才能使极坐标图居中,以使
x
在其中心显示?
It's "centered", but the radius starts at a negative value, something around -0.04
in your case. 它是“居中的”,但半径从负值开始,在您的情况下约为
-0.04
。 Try setting rmin
after you have plotted your point: 绘制好点后,尝试设置
rmin
:
import matplotlib.pyplot as plt
ax = plt.subplot(111, projection='polar')
ax.plot([0], [0], marker = 'x')
ax.set_rmax(5)
ax.set_rmin(0)
plt.show()
This gives a single little x
exactly in the middle of the circle with radius 5
. 这将在半径为
5
的圆的正中给出一个小x
。
The problem usually does not appear if you plot multiple points with many interesting values, because it then sets the radius range to more sane defaults. 如果用多个有趣的值绘制多个点,通常不会出现此问题,因为这样会将半径范围设置为更合理的默认值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.