如何更改情节颜色

发布于 2025-02-06 02:40:06 字数 996 浏览 2 评论 0原文

from fbprophet import Prophet
from pandas import to_datetime
df=df_date_pink[["Date of Travel",'Number of Passengers']]
df.columns = ['ds', 'y']
df['ds']= to_datetime(df['ds'])
model = Prophet()
model.fit(df)
future = list()
for i in range(1, 13):
    date = '2019-%02d' % i
    future.append([date])
future = pd.DataFrame(future)
future.columns = ['ds']
future['ds']= to_datetime(future['ds'])
forecast = model.predict(future)
print(forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].head())
model.plot(forecast)
plt.gca().get_lines()[0].set_color("deeppink")
plt.title("Pink Cabs Number of Passengers and Its Forecast For The Next Year", size=15)
plt.xlabel("Dates", size=15)
plt.ylabel("Number of Passengers", size=15)
plt.show()

运行时,我会得到此

”由上述代码产生的“视觉”

我也想要预测的线和阴暗的区域“ deeppink”。我该怎么做?

from fbprophet import Prophet
from pandas import to_datetime
df=df_date_pink[["Date of Travel",'Number of Passengers']]
df.columns = ['ds', 'y']
df['ds']= to_datetime(df['ds'])
model = Prophet()
model.fit(df)
future = list()
for i in range(1, 13):
    date = '2019-%02d' % i
    future.append([date])
future = pd.DataFrame(future)
future.columns = ['ds']
future['ds']= to_datetime(future['ds'])
forecast = model.predict(future)
print(forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].head())
model.plot(forecast)
plt.gca().get_lines()[0].set_color("deeppink")
plt.title("Pink Cabs Number of Passengers and Its Forecast For The Next Year", size=15)
plt.xlabel("Dates", size=15)
plt.ylabel("Number of Passengers", size=15)
plt.show()

When it is runned I get this

visual produced by the above code

I also want the forecasted lines and the shadowy area "deeppink" as well. How can I do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

轻拂→两袖风尘 2025-02-13 02:40:06
plt.gca().get_lines()[1].set_color("deeppink")
plt.gca().get_lines()[1].set_color("deeppink")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文