python 绘图 异常点绘制使用 ax.plot(abnormal_points['ds'], abnormal_points['y'], "rX", label='abnormal points')

摘要:
fig=plt.fig(facecolor='w',fig=ax.get_ffigure()fcst_t=fcst['ds'].dt.to_pydatetime()ax.plot(m.histor['ds'].dt.to_prydatetime),label='y')ax.legend()ax.prlot(fcst_t,

python 绘图 异常点绘制使用 ax.plot(abnormal_points['ds'], abnormal_points['y'], "rX", label='abnormal points')第1张

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", label='abnormal points')》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇清北学堂北京大学吴耀轩神仙讲课day5摘要安卓中多线程间通信方式下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Python3调用企业微信用于告警

代码实现请见文末 前段时间利用py爬虫抓取一些网页信息,然后通过wxpy发送到微信群,以用作日常告警,感觉还是很方便。 但好景不长,我的小号微信被腾讯封了(很常见咯), 显示无法登录网页版微信,至今已经有半个多月了。 怎么办,已经体验过微信告警的方便后,无法回归原始人工查看了。思来想去,决定探(bai)索(du)Python调用微信企业号试试看; 一、申...

yii框架中findall方法取数据使用总结,包括select各种条件,where条件,order by条件,limit限制等

在yii框架中可以使用映射类的find方法取出一条数据或者用findall方法取出数条数据来,那么如何按照所需条件来取数据呢,主要用到了CDbCriteria这个类,这个类是yii自带的操作数据库的支持类,可以作为参数传递给find等方法,这里用findall做个例子: 比如我要取出videoinfo表中的'v_id','title','big_class...

网页图片很多时,加载完后再加载图片(defer:延迟加载)

图片影响页面加载速度,可以先加载完页面,再去加载图片。 defer:告诉浏览器,这里面的js代码不影响网页脚本解析,可以解析完html脚本再执行这段js代码(个人理解)。 网页代码:<img src="http://t.zoukankan.com/grey.gif" data-original="img/53a1820f5866c.png"/>...

使用pandas处理大型CSV文件(转)

# -*- coding:utf-8 -*- ''' CSV 常用API 1)reader(csvfile[, dialect='excel'][, fmtparam]),主要用于CSV 文件的读取,返回一个 reader 对象用于在CSV 文件内容上进行行迭代。 参数: csvfile,需要是支持迭代(Iterat...

vue+elementui 中 @keyup 键盘上下左右移动聚焦

            <template>             <el-table :data="CreditUnclearOutlineList" border style=" 100%" ref="table"> <el-table-co...

whl包构建

安装依赖 pip install whell pip install twine 参数对应 标注*号的为重要参数 描述性参数 —— 提供包信息,供PiPy识别管理 描述性参数,只是作为包的信息用的,没有特殊作用,可有可无。 参数 类型 说明 *name str 包名称 *version str 包版本 *author str 程序的作者...