我想在資料庫上使用 matplotlib 庫中的 scatter 函式,但我根本不能。
下面是我的代碼和錯誤:
import matplotlib as plt
y = df["price"]
x = df["engine-size"]
plt.scatter(x,y)
錯誤:AttributeError:模塊“matplotlib”沒有屬性“scatter”
uj5u.com熱心網友回復:
您必須將 matplotlib.pyplot 作為 plt 匯入。參見此處的示例https://matplotlib.org/stable/gallery/shapes_and_collections/scatter.html#sphx-glr-gallery-shapes-and-collections-scatter-py
uj5u.com熱心網友回復:
以這種方式匯入;
從 matplotlib 匯入 pyplot 作為 plt
然后再次運行您的代碼 這應該可以作業
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/390064.html
標籤:Python matplotlib 分散
