python 绘图 异常点绘制使用 ax.plot(abnormal_points['ds'], abnormal_points['y'], "rX
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python 绘图 异常点绘制使用 ax.plot(abnormal_points['ds'], abnormal_points['y'], "rX,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1374字,纯文字阅读大概需要2分钟。
内容图文
![python 绘图 异常点绘制使用 ax.plot(abnormal_points[](/upload/InfoBanner/zyjiaocheng/857/f6fc49ade78643cf836c4c30161e1792.jpg)
from matplotlib import pyplot as plt def my_plot(title, m, fcst, ax=None, uncertainty=True, plot_cap=True, xlabel='ds', ylabel='y', abnormal_points=None ): """Plot the Prophet forecast. Parameters ---------- m: Prophet model. fcst: pd.DataFrame output of m.predict. ax: Optional matplotlib axes on which to plot. uncertainty: Optional boolean to plot uncertainty intervals. plot_cap: Optional boolean indicating if the capacity should be shown in the figure, if available. xlabel: Optional label name on X-axis ylabel: Optional label name on Y-axis Returns ------- A matplotlib figure. """ if ax is None: fig = plt.figure(facecolor='w', figsize=(10, 6)) ax = fig.add_subplot(111) else: fig = ax.get_figure() fcst_t = fcst['ds'].dt.to_pydatetime() ax.plot(m.history['ds'].dt.to_pydatetime(), m.history['y'], 'k.', label='y') ax.legend() ax.plot(fcst_t, fcst['yhat'], ls='-', c='#0072B2', label='predicted y') ax.legend() ax.fill_between(fcst_t, 0, fcst['yhat_upper'], color='#0072B2', alpha=0.2, label='predicted upper y') # ax.plot(fcst_t, fcst['yhat_upper'], ls='--', color='#0072B2', alpha=0.2, label='predicted upper y') ax.legend() if abnormal_points is not None: ax.plot(abnormal_points['ds'], abnormal_points['y'], "rX", label='abnormal points') ax.legend() ax.set_title(title) ax.grid(True, which='major', c='gray', ls='-', lw=1, alpha=0.2) ax.set_xlabel(xlabel) ax.set_ylabel(ylabel) fig.tight_layout() plt.savefig("png/{}.png".format(title)) return fig
内容总结
以上是互联网集市为您收集整理的python 绘图 异常点绘制使用 ax.plot(abnormal_points['ds'], abnormal_points['y'], "rX全部内容,希望文章能够帮你解决python 绘图 异常点绘制使用 ax.plot(abnormal_points['ds'], abnormal_points['y'], "rX所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。