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')的更多相关文章

  1. Python使用matplotlib绘制三维曲线

    本文主要演示如何使用matplotlib绘制三维图形 代码如下: # -*- coding: UTF-8 -*- import matplotlib as mpl from mpl_toolkits. ...

  2. Python绘图matplotlib

    转自http://blog.csdn.net/ywjun0919/article/details/8692018 Python图表绘制:matplotlib绘图库入门 matplotlib 是pyth ...

  3. Python 绘图与可视化 matplotlib(上)

    参考链接:https://www.cnblogs.com/dudududu/p/9149762.html 更详细的:https://www.cnblogs.com/zhizhan/p/5615947. ...

  4. python绘图:matplotlib和pandas的应用

    在进行数据分析时,绘图是必不可少的模式探索方式.用Python进行数据分析时,matplotlib和pandas是最常用到的两个库.1.matplotlib库的应用准备工作如下:打开ipython,输 ...

  5. Python绘图之matplotlib基本语法

    Matplotlib 是一个 Python 的 2D绘图库,通过 Matplotlib,开发者可以仅需要几行代码,便可以生成绘图,直方图,功率谱,条形图,错误图,散点图等.当然他也是可以画出3D图形的 ...

  6. Python绘图工具Plotly的简单使用

    1.Plotly被称为史上最好的绘图工具之一,为了更好的展示金融数据的复杂性. Plotly的官方网站为:https://plot.ly/ python量化的关键是金融数据可视化,无论是传统的K线图, ...

  7. Python使用plotly绘制数据图表的方法

    转载:http://www.jb51.net/article/118936.htm 本篇文章主要介绍了Python使用plotly绘制数据图表的方法,实例分析了plotly绘制的技巧. 导语:使用 p ...

  8. 【python笔记】使用matplotlib,pylab进行python绘图

    一提到python绘图,matplotlib是不得不提的python最著名的绘图库,它里面包含了类似matlab的一整套绘图的API.因此,作为想要学习python绘图的童鞋们就得在自己的python ...

  9. python实现并绘制 sigmoid函数,tanh函数,ReLU函数,PReLU函数

    Python绘制正余弦函数图像 # -*- coding:utf-8 -*- from matplotlib import pyplot as plt import numpy as np impor ...

随机推荐

  1. 06: AJAX全套 & jsonp跨域AJAX

    目录: 1.1 AJAX介绍 1.2 jQuery AJAX(第一种) 1.3 原生ajax(第二种) 1.4 iframe“伪”AJAX(第三种) 1.5 jsonp跨域请求 1.6 在tornad ...

  2. 20145101《Java程序设计》第一周学习总结

    20145101 <Java程序设计>第1周学习总结 教材学习内容总结 开学的第一周,通过课上老师的介绍和课下阅读教材我简单的了解java的发展历程,了解了JVM.JRE.JDK分别是什么 ...

  3. 20145216史婧瑶《网络对抗》Web基础

    20145216史婧瑶<网络对抗>Web基础 实验问题回答 (1)什么是表单 表单在网页中主要负责数据采集功能.一个表单有三个基本组成部分: 表单标签.表单域.表单按钮. (2)浏览器可以 ...

  4. Bootstrap 使用教程 与jQuery的Ajax方法

    jQuery.ajax(url,[settings]) 更加详细的内容参考    jQuery API 中文在线手册 概述 通过 HTTP 请求加载远程数据. jQuery 底层 AJAX 实现.简单 ...

  5. [BZOJ1497]最大获利

    Description 新的技术正冲击着手机通讯市场,对于各大运营商来说,这既是机遇,更是挑战.THU集团旗下的CS&T通讯公司在新一代通讯技术血战的前夜,需要做太多的准备工作,仅就站址选择一 ...

  6. spring与spring-data-redis整合redis

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  7. BZOJ1307: 玩具 单调队列

    Description 小球球是个可爱的孩子,他喜欢玩具,另外小球球有个大大的柜子,里面放满了玩具,由于柜子太高了,每天小球球都会让妈妈从柜子上拿一些玩具放在地板上让小球球玩. 这天,小球球把所有的N ...

  8. [JavaScript] - 7kyu

    Johnny is a boy who likes to open and close lockers. He loves it so much that one day, when school w ...

  9. 使用Apache Kylin搭建企业级开源大数据分析平台

    转:http://www.thebigdata.cn/JieJueFangAn/30143.html 我先做一个简单介绍我叫史少锋,我曾经在IBM.eBay做过大数据.云架构的开发,现在是Kylige ...

  10. 06_Flume_interceptor_时间戳+Host

    1.目标场景 2.flume agent配置文件 # define agent name, source/sink/channel name a1.sources = r1 a1.sinks = k1 ...