gpt4 book ai didi

python - 为什么图中有两点无法显示(matplotlib)?

转载 作者:行者123 更新时间:2023-12-02 03:15:05 26 4
gpt4 key购买 nike

图1显示数据点1

1 : enter image description here

我在python中使用matplotlib绘制了图形,但是数据点无法完全显示。图中右下角有两个点没有显示。这两个坐标分别是(-0.6731984257692413, 6.0)、(-0.7105983383119769, 7.0)。我不知道为什么。有人可以帮忙吗?

import matplotlib.pyplot as plt
theta = [0.8975979010256552, 2.6927937030769655, 0, -0.6731984257692413, 0.0, -1.7951958020513104, -0.8975979010256552, -1.7951958020513104, -2.6927937030769655, -0.5235987755982988, -0.59839860068377, -0.8975979010256552, -1.1967972013675403, 1.7951958020513104, -0.5609986881410344, -0.59839860068377, -0.6357985132265057, -0.7105983383119769]
r = [1.0, 0.5, 0, 6.0, 1.0, 1.5, 1.0, 1.0, 1.0, 4.5, 4.0, 4.0, 4.0, 0.5, 4.5, 4.5, 4.5, 7.0]
colors = [1.13290242331, 0.81108163706000003, 0, 0.94180655750400011, 0.90356396220000001, 0.946707749135, 1.09650064153, 1.2068422679700002, 1.1150923324999999, 2.4619798379700004, 0.83030335877799999, 0.87957520389799992, 0.872155341769, 0.92537488526299994, 2.70431872671, 1.10024483211, 0.89817718522000012, 1.1547139643100002]

plt.subplot(111,polar=True)
cc=plt.scatter(theta,r,c=colors,cmap=plt.cm.hsv)

cc.set_alpha(0.75)
plt.grid(color='y', alpha=0.8, linestyle='dashed', linewidth=1)
plt.colorbar()
plt.thetagrids([30])
plt.show()

最佳答案

这是 a bug in matplotlibwas fixed by March 2019 。它可能会在 3.2.0 版本中修复。

在仍然存在错误的 matplotlib 版本上,解决方法是手动指定轴限制:

plt.ylim([0, max(r)+1])

关于python - 为什么图中有两点无法显示(matplotlib)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39553030/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com