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

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')的更多相关文章
- Python使用matplotlib绘制三维曲线
本文主要演示如何使用matplotlib绘制三维图形 代码如下: # -*- coding: UTF-8 -*- import matplotlib as mpl from mpl_toolkits. ...
- Python绘图matplotlib
转自http://blog.csdn.net/ywjun0919/article/details/8692018 Python图表绘制:matplotlib绘图库入门 matplotlib 是pyth ...
- Python 绘图与可视化 matplotlib(上)
参考链接:https://www.cnblogs.com/dudududu/p/9149762.html 更详细的:https://www.cnblogs.com/zhizhan/p/5615947. ...
- python绘图:matplotlib和pandas的应用
在进行数据分析时,绘图是必不可少的模式探索方式.用Python进行数据分析时,matplotlib和pandas是最常用到的两个库.1.matplotlib库的应用准备工作如下:打开ipython,输 ...
- Python绘图之matplotlib基本语法
Matplotlib 是一个 Python 的 2D绘图库,通过 Matplotlib,开发者可以仅需要几行代码,便可以生成绘图,直方图,功率谱,条形图,错误图,散点图等.当然他也是可以画出3D图形的 ...
- Python绘图工具Plotly的简单使用
1.Plotly被称为史上最好的绘图工具之一,为了更好的展示金融数据的复杂性. Plotly的官方网站为:https://plot.ly/ python量化的关键是金融数据可视化,无论是传统的K线图, ...
- Python使用plotly绘制数据图表的方法
转载:http://www.jb51.net/article/118936.htm 本篇文章主要介绍了Python使用plotly绘制数据图表的方法,实例分析了plotly绘制的技巧. 导语:使用 p ...
- 【python笔记】使用matplotlib,pylab进行python绘图
一提到python绘图,matplotlib是不得不提的python最著名的绘图库,它里面包含了类似matlab的一整套绘图的API.因此,作为想要学习python绘图的童鞋们就得在自己的python ...
- python实现并绘制 sigmoid函数,tanh函数,ReLU函数,PReLU函数
Python绘制正余弦函数图像 # -*- coding:utf-8 -*- from matplotlib import pyplot as plt import numpy as np impor ...
随机推荐
- Python3 打开 https 链接,异常:“SSL: CERTIFICATE_VERIFY_FAILED”
Python3 打开 https 链接,异常:“SSL: CERTIFICATE_VERIFY_FAILED” 一.问题 Python2.7.9 之后,当使用urllib.urlopen打开一个 ht ...
- JSmpeg-用JavaScript编写的视频播放器
使用说明:https://github.com/phoboslab/jsmpeg ffmpeg -i rtmp://abc/ccc/111 -f mpegts -codec:v mpeg1video ...
- HTTP If-Modified-Since引发的浏览器缓存汇总
在看Spring中HttpServlet的Service方法时,对于GET请求,代码逻辑如下: if (method.equals(METHOD_GET)) { long lastModified = ...
- Spring通过ApplicationContext主动获取bean
有些场景无法通过AutoWired和compoment注解传递进来,于是希望通过Spring context主动去获取beandemo: package com.qhong.Util; import ...
- Linq join right join left join
代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Syst ...
- SQL Over
与over函数结合的几个函数 create table #tab(A varchar(), B varchar()) insert into #tab select 'A1', 'B1' union ...
- 第几天|2018年蓝桥杯B组题解析第一题-fishers
标题:第几天 2000年的1月1日,是那一年的第1天. 那么,2000年的5月4日,是那一年的第几天? 注意:需要提交的是一个整数,不要填写任何多余内容. 思路:计算日期,用excel计算两个日期的差 ...
- Codeforces Beta Round #16 div 2 C.Monitor最大公约数
C. Monitor time limit per test 0.5 second memory limit per test 64 megabytes input standard input ou ...
- poj 2186 Popular Cows tarjan
Popular Cows Description Every cow's dream is to become the most popular cow in the herd. In a herd ...
- ros python 重置位置
#!/usr/bin/env python import rospy import math import sys import commands import yaml from tf import ...