【发布时间】:2020-04-30 23:06:52
【问题描述】:
我想让 x 轴上的日期看起来更漂亮,目前甚至无法读取日期。最好的方法是什么。 下面是代码,也是实际的图形图片
import matplotlib.pyplot as plt
import pandas as pd
import pandas as pd
df = dataset
# gca stands for 'get current axis'
ax = plt.gca()
y1 = df['Predicted_Lower']
y2 = df['Predicted_Upper']
x = df['Date']
ax.fill_between(x,y1, y2, facecolor="#CC6666", alpha=0.7)
df.plot(kind='line',x='Date',y='Predicted_Lower',color='white',ax=ax)
df.plot(kind='line',x='Date',y='Predicted_Upper',color='white', ax=ax)
df.plot(kind='line',x='Date',y='Predicted', color='yellow', ax=ax)
df.plot(kind='line',x='Date',y='Actuals', color='green', ax=ax)
plt.xticks(rotation=45)
plt.show()
【问题讨论】:
-
我相信您正在寻找matplotlib.org/3.1.1/gallery/ticks_and_spines/… 和matplotlib.org/3.1.1/gallery/text_labels_and_annotations/… 的组合。如果您发布一些我们可以复制的示例数据,将更容易提供更详细的答案。
-
@MatthewBorish 它已连接到 mysqlserver
标签: python-3.x pandas matplotlib data-visualization predictive