Python 带有标记的散点图,根据表示的点的数量改变大小
我正在绘制一个简单的散点图: 它正确地表示了我的数据,但是有许多带有坐标(1.00,1.00)的数据点,并且在绘图中,它们显示在单个标记(右上角)下。我想有一个功能,改变每一个标记的大小根据它所代表的点数。谢谢你的帮助。这是我的密码:Python 带有标记的散点图,根据表示的点的数量改变大小,python,scatter-plot,Python,Scatter Plot,我正在绘制一个简单的散点图: 它正确地表示了我的数据,但是有许多带有坐标(1.00,1.00)的数据点,并且在绘图中,它们显示在单个标记(右上角)下。我想有一个功能,改变每一个标记的大小根据它所代表的点数。谢谢你的帮助。这是我的密码: def saveScatter(figureTitle, xFeature, yFeature, xTitle, yTitle): ''' save a scatter plot of xFeatures vs yFeatures ''' fig =
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
散点法有一个
s
关键字参数,可用于调整应查看的标记大小。在您当前的框架中,可能需要进行大量的修改才能集成思想您是否有示例数据,即使只有几行?