python - 标记根据表示点的数量改变大小的散点图
问题描述
它正确地表示了我的数据,但是有许多坐标为 (1.00,1.00) 的数据点,并且在图中,它们出现在一个标记下(右上角)。我想要一个功能,根据它所代表的点数来改变每个标记的大小。将不胜感激任何帮助。这是我的代码:
def saveScatter(figureTitle, xFeature, yFeature, xTitle, yTitle):
''' save a scatter plot of xFeatures vs yFeatures '''
fig = plt.figure(figsize=(8, 6), dpi=300)
ax = fig.add_subplot(111)
ax.scatter(dfModuleCPositives[names[xFeature]][:], dfModuleCPositives[names[yFeature]][:], c='r', marker='x', alpha=1, label='Module C Positives')
ax.scatter(dfModuleCNegatives[names[xFeature]][:], dfModuleCNegatives[names[yFeature]][:], c='g', alpha=0.5, label='Module C Negatives')
ax.scatter(dfModuleDPositives[names[xFeature]][:], dfModuleDPositives[names[yFeature]][:], c='k', marker='x', alpha=1, label='Module D Positives')
ax.scatter(dfModuleDNegatives[names[xFeature]][:], dfModuleDNegatives[names[yFeature]][:], c='b', alpha=0.5, label='Module D Negatives')
ax.set_xlabel(xTitle, fontsize=10)
ax.set_ylabel(yTitle, fontsize=10)
ax.set_title(figureTitle)
ax.grid(True)
ax.legend(loc="lower right")
fig.tight_layout()
plt.show()
return ax
解决方案
推荐阅读
- python - 带有 Model.Fit() 的 Keras InvalidArgumentError
- ruby - 以下两个代码片段之间有什么区别吗?
- c# - 使用 GraphQ 避免 HTTP 开销
- swift - 在另一个不在标签栏中的视图控制器中显示标签栏项目
- django - Django 如果模板中的表为空,则显示其他内容
- php - XAMPP 发送邮件问题
- java - 编辑器不包含主要类型,即使它包含
- javascript - 如何查找包含某个数字的任何数字 - 例如 1323 包含数字“2”
- php - 我需要从数据库(opencart)添加列也检查问题或否
- c# - 使用 Linq 在 C# 中合并 2 个字典(Concat 未按预期工作)