python pyplot中axis_Python Pyplot xaxis未显示在图形上
pyplot未在圖形上顯示x軸:import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv('sitka_weather_2014.csv')
df['AKST'] = pd.to_datetime(df.AKST)
df['Dates'] = df['AKST'].dt.strftime('%b %d, %Y')
df.set_index("Dates", inplace= True)
# Plot Data
fig = plt.figure(dpi=256, figsize=(14, 7))
plt.title("Daily high and low temperature - 2014")
df['Max TemperatureF'].plot(linewidth=1, c='blue', label="Max Temperature °F")
df['Min TemperatureF'].plot(linewidth=1, c='red', label="Min Temperature °F")
plt.grid(True)
plt.rc('grid', linestyle=":", linewidth=1, color='gray')
plt.legend(loc='upper left')
plt.xlabel('', fontsize=10)
plt.ylabel("Temperature (°F)", fontsize=10)
plt.tick_params(axis='both', which='major', labelsize=10)
fig.autofmt_xdate(rotation=45)
plt.show()
x軸應該是包含日期的Pandas數據幀(df)的索引。
總結
以上是生活随笔為你收集整理的python pyplot中axis_Python Pyplot xaxis未显示在图形上的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 老师多少钱一个月啊?
- 下一篇: python保存为xlsb_Read X