我如何在 pycharm 2019 IDE 中创建散点图
how do i create a scatter plot in pycharm 2019 IDE
import pandas as pd
import matplotlib.pyplot as plt
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
path = "https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/DA0101EN/auto.csv"
df = pd.read_csv(path)
headers = ["symboling","normalized-losses","make","fuel-type","aspiration", "num-of-doors","body-style",
"drive-wheels","engine-location","wheel-base", "length","width","height","curb-weight","engine-type",
"num-of-cylinders", "engine-size","fuel-system","bore","stroke","compression-ratio","horsepower",
"peak-rpm","city-mpg","highway-mpg","price"]
df.columns = headers
y = df["price"]
x = df["engine-size"]
plt.xlabel("engine")
plt.ylabel("price")
plt.title("Price Vs Engine size")
plt.scatter(x, y)
然后我得到 "finished with exit code 0" 但我没有看到任何散点图
你试过在最后使用 plt.show()
吗?
import pandas as pd
import matplotlib.pyplot as plt
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
path = "https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/DA0101EN/auto.csv"
df = pd.read_csv(path)
headers = ["symboling","normalized-losses","make","fuel-type","aspiration", "num-of-doors","body-style",
"drive-wheels","engine-location","wheel-base", "length","width","height","curb-weight","engine-type",
"num-of-cylinders", "engine-size","fuel-system","bore","stroke","compression-ratio","horsepower",
"peak-rpm","city-mpg","highway-mpg","price"]
df.columns = headers
y = df["price"]
x = df["engine-size"]
plt.xlabel("engine")
plt.ylabel("price")
plt.title("Price Vs Engine size")
plt.scatter(x, y)
然后我得到 "finished with exit code 0" 但我没有看到任何散点图
你试过在最后使用 plt.show()
吗?