import matplotlib.pyplot as pltimport pandas as pdimport pylab as plimport numpy as np%matplotlib inline!wget -O FuelConsumption.csv https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses- data/CognitiveClass/ML0101ENv3/labs/FuelConsumptionCo2.csvdf = pd.read_csv("FuelConsumption.csv")df.head()df1 = df[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_COMB','CO2EMISSIONS']]df1.head(9)plt.scatter(df1.ENGINESIZE , df1.CO2EMISSIONS , color = "black")plt.xlabel=("enginesize")plt.ylabel=("emission")plt.show()当我尝试运行这段代码时,我得到了没有轴标签的散点图。如果有人可以帮助我,我该如何获得轴标签?
1 回答
交互式爱情
TA贡献1712条经验 获得超3个赞
您需要将标签名称传递给xlabel和ylabel。如果它抛出错误 -TypeError: 'str' object is not callable然后重新启动 ipython 内核
import matplotlib.pyplot as plt
import pandas as pd
import pylab as pl
import numpy as np
%matplotlib inline
df = pd.read_csv("FuelConsumption.csv")
df.head()
df1 = df[['ENGINESIZE','CYLINDERS','FUELCONSUMPTION_COMB','CO2EMISSIONS']]
df1.head(9)
plt.scatter(df1.ENGINESIZE , df1.CO2EMISSIONS , color = "black")
plt.xlabel("enginesize")
plt.ylabel("emission")
plt.show()
添加回答
举报
0/150
提交
取消