繁体   English   中英

Matplotlib 当我想用

[英]Matplotlib doesn't show both datasets points on the figure when I want to create scatter plot with

我确信我做的一切都是正确的,但最终我得到的结果是一个只显示第二个数据集数据的散点 plot。

  fig = plt.figure()
  ax1 = fig.add_subplot(111)
  ax1.scatter(train["ENGINESIZE"], train["CO2EMISSIONS"], color = "green")
  ax1.scatter(test["ENGINESIZE"], test["CO2EMISSIONS"], color = "red")
  plt.xlabel("Engine Size")
  plt.ylabel("Emission")
  
  plt.show()

在这里,您可以在下面的链接中看到我的 output 中发生了什么。 它仅显示 output 中的红色数据(测试数据)。

请问“下面的输出链接”在哪里? 现在我只能想象你在描述什么。

如果两个图具有相同的轴,它也会有所帮助。 也就是说,两者都有相同的 x 轴,然后它们可以在 y 轴上变化。

如果是这样:

fig, ax = plt.subplots()

df.plot(kind = 'scatter', x= train["ENGINESIZE"], y = train["CO2EMISSIONS"], color = {'g'}, ax = ax)
df.plot(kind = 'scatter', x= test["ENGINESIZE"], y = test["CO2EMISSIONS"], color = {'r'}, ax = ax)
plt.xlabel()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM