【发布时间】:2016-02-10 11:07:10
【问题描述】:
我有一个数据,可以在散点图中使用。
我也有相同数据的标签。所以我使用条件着色:
# import needed things
fig = plt.figure()
r = fig.add_subplot(121)
r.scatter(np.arange(500), X[ :500, 0] c = Y[:500]
# x and y labels set here
g = fig.add_subplot(122)
g.scatter(np.arange(500), X[ :500, 1] c = Y[:500]
# x and y labels set here
plt.show()
我还需要一个图例,表明哪种类型有哪种颜色。我试过这个:
plt.legend((r, g), ("one", "zero"), scatterpoints = 1, loc = "upper left")
但我收到警告
.../site-packages/matplotlib/legend.py:633: UserWarning: Legend does not support <matplotlib.axes._subplots.AxesSubplot object at 0x7fe37f460668> instances.
A proxy artist may be used instead.
并且不显示图例。
【问题讨论】:
标签: python matplotlib scatter-plot