簡體   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