问题描述
我试图通过导入Excel文件来绘制对数图来绘制图形。
这是我的代码,但看来我做错了。
import matplotlib.pyplot as plt
import pandas as pd
df=pd.read_excel("C:\\users\mycomputer\\myfile.xlsx")
df.plot(x,y)
plt.show()
解决方法
这是一个简短的示例:
# from first cell in Jupyter notebook
import matplotlib.pyplot as plt
import pandas as pd
s = pd.Series(data=[1,10,100,1_000,10_000],index=[1,2,3,4,5])
# from second cell in Jupyter notebook
fig,ax = plt.subplots(figsize=(8,5))
ax.plot(s)
ax.set(xscale='log',yscale='log',xlabel='x-axis',ylabel='y-axis',title='Plot Title Here')
plt.show();
这里是Matplotlib的一个很好的参考:https://jakevdp.github.io/PythonDataScienceHandbook/04.00-introduction-to-matplotlib.html