python - 我的散点图只显示数据的一部分
问题描述
import numpy as np
import matplotlib.pyplot as plt
# Create data
N = 60
g1 = (0.6 + 0.6 * np.random.rand(N), np.random.rand(N))
g2 = (0.4+0.3 * np.random.rand(N), 0.5*np.random.rand(N))
g3 = (0.3*np.random.rand(N),0.3*np.random.rand(N))
data = (g1, g2, g3)
colors = ("red", "green", "blue")
groups = ("coffee", "tea", "water")
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
for data, color, group in zip(data, colors, groups):
x, y = data
ax.scatter(x, y, alpha=0.8, c=color, edgecolors='none', s=30, label=group)
plt.title('Matplot scatter plot')
plt.legend(loc=2)
plt.show()
创建 pyplot 图之前的任何代码都不能更改。似乎 for 循环无法正常工作。我不确定问题是什么。没有任何错误。
解决方案
推荐阅读
- csv - 从 Octave 中的 CSV 文件中读取日期
- reactjs - 自定义挂钩:并非所有类型为“xxx”的成分都是可调用的
- pyspark - 从 Date 获取周开始日期和周结束日期
- cordova - 离子电容器如何使用可在平台浏览器上运行的cordova插件
- android - Ad Manager、无效流量和点击
- android - 在 Kotlin 中使用 JSON 数组中的值对日期进行排序的有效方法
- java - HashSet 内部使用HashMap还是hastable(小写)数据结构?
- angular - 如何在 VSCode 中调试 Angular 9 库
- css - 如何在角度6的任何给定坐标处在图像上打印动态文本
- visual-studio - 在 Visual Studio 中查找参考不起作用(行号显示为零)