感谢这个很有帮助post , 我终于想出了如何制作极地填充轮廓图。然而,当我进入下一步并尝试向同一个图中添加一个散点时,我遇到了一些问题。这是原始脚本:
import numpy as np
import matplotlib.pyplot as plt
#-- Generate Data -----------------------------------------
# Using linspace so that the endpoint of 360 is included...
azimuths = np.radians(np.linspace(0, 360, 20))
zeniths = np.arange(0, 70, 10)
r, theta = np.meshgrid(zeniths, azimuths)
values = np.random.random((azimuths.size, zeniths.size))
#-- Plot... ------------------------------------------------
fig, ax = plt.subplots(subplot_kw=dict(projection='polar'))
ax.contourf(theta, r, values)
plt.show()
产生这张图片的是:
如果我还添加一个散点图:
#-- Plot... ------------------------------------------------
fig, ax = plt.subplots(subplot_kw=dict(projection='polar'))
ax.contourf(theta, r, values)
ax.scatter(np.radians(140), 40, s=20, c='White')
我得到的是这张图片:
为什么我在填充的轮廓和轴之间得到白色的粗边框?我该如何摆脱它?
非常感谢!
糟糕,抱歉,我在问了我的问题两分钟后才想到答案。我刚刚意识到添加散点图会以某种方式改变轴限制。将轴强制设置为所需的间隔可以解决问题。
fig, ax = plt.subplots(subplot_kw=dict(projection='polar'))
ax.contourf(theta, r, values)
ax.scatter([np.radians(140)], [40], s=20, c='White')
ax.set_rmax(60)
ax.set_rmin(0)
我想我还是可以留下这个问题,它仍然可以对其他用户有所帮助。
我是一名优秀的程序员,十分优秀!