[英]matplotlib how to visualize scatter & plot
I want to connect scatter by line and show legend.. So I use plt.plot and plt.scatter.. but plot and scatter have each legend and show duplication.我想按行连接散点图并显示图例..所以我使用 plt.plot 和 plt.scatter.. 但 plot 和 scatter 有每个图例并显示重复。 I think only plot has legend information because I define plt.legend before plt.scatter...
我认为只有情节有图例信息,因为我在 plt.scatter 之前定义了 plt.legend ...
Can you tell me nice method to connect scatter?你能告诉我连接分散的好方法吗?
Can you tell me why scatter has legend??你能告诉我为什么 scatter 有传说吗??
for index in range(len(xvalue_list)):
plt.plot(xvalue_list, yvalue_list)
plt.legend(graph_legend_list[index], fontsize = '10', fancybox=True)
plt.scatter(xvalue_list, yvalue_list)
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.show()
You are creating 4 legends, where each character of the desired label is mapped to one of the elements in the plot.您正在创建 4 个图例,其中所需标签的每个字符都映射到图中的元素之一。 This is clearly not useful.
这显然没有用。 Instead, create one single legend.
相反,创建一个图例。
for index in range(len(xvalue_list)):
plt.plot(xvalue_list, yvalue_list, marker="o", label=graph_legend_list[index])
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.legend(fontsize = '10', fancybox=True)
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.