Python绘制带误差线的图形 Python plots with error bands
If you want to plot a function curve with multiple parameters with errors, one way to visualize the error is to use a band plot.
如果您想绘制带有误差的多参数函数曲线,一种可视化误差的方式是使用带状图。
A band plot is similar to a line plot, but instead of a single line, it shows a shaded band around the line to represent the uncertainty in the function due to the uncertainties in the parameters. The band is usually defined by plotting the function at a range of parameter values that span the range of their uncertainties.
带状图类似于线图,但不同的是,它不是显示单条线,而是在线周围显示着色带,以表示由于参数的不确定性而导致的函数不确定性。该带通常由在参数值范围内绘制函数而定义,这些参数值跨越其不确定性范围。
Here is an example using matplotlib:
import numpy as np
import matplotlib.pyplot as plt# Define the function with multiple parameters
def func(x, a, b, c):return a*np.sin(b*x) + c# Define the parameter values and uncertainties
a = 2.0
b = 1.0
c = 0.5
a_err = 0.1
b_err = 0.2
c_err = 0.2# Define the range of x values
x = np.linspace(0, 10, 100)# Calculate the function values at the nominal parameter values and at +/- 1 sigma for each parameter
y_nominal = func(x, a, b, c)
# Calculate the function values at the nominal parameter values and at +/- 1 sigma for each parameter
y_nominal = func(x, a, b, c)
# y_upper = func(x, a+a_err, b+b_err, c+c_err)
y_upper = func(x, a, b, c+c_err)
# y_lower = func(x, a-a_err, b-b_err, c-c_err)
y_lower = func(x, a, b, c-c_err)# Plot the function curve with a shaded band representing the error
plt.plot(x, y_nominal, label='Nominal')
plt.fill_between(x, y_upper, y_lower, alpha=0.5, label='Error')
plt.legend()
plt.xlabel('x')
plt.ylabel('y')
plt.show()
This will produce a plot with the function curve and a shaded band representing the error due to the uncertainties in the parameters. The size of the band reflects the size of the uncertainties.
这将生成一个包含函数曲线和代表参数不确定性误差的带状区域的图表。带状区域的大小反映了不确定性的大小。
Python绘制带误差线的图形 Python plots with error bands相关推荐
- python绘制带误差线的条形图
绘制格式: plt.bar(index, values, yerr = std, error_kw = {'ecolor' : '0.2', 'capsize' :6}, alpha=0.7) yer ...
- matlab 条形图误差线,数据可视化系列:手把手教你绘制带误差线的条形图
原标题:数据可视化系列:手把手教你绘制带误差线的条形图 条形图可以用于展示数据不同分类下的均值.中位数.标准差和置信区间等,Excel可以实现,但对于带误差线的条形图而言,还是比较麻烦的.R语言的基础 ...
- R - ggplot绘制带误差线的柱状图
ggplot绘制带误差线的柱状图 利用ggplot2 数据格式转换并做统计计算 绘制图形 ## 模拟 ## 导入包 library(ggplot2) library(reshape2) library ...
- Matlab绘制带误差线的柱状图
Matlab可绘制带误差线的柱状图(需下载barweb (BARgraph With Error Bars) - File Exchange - MATLAB Central并设置路径),成图如下所示 ...
- R语言绘制带误差线的条形图
条形统计图是用一个单位长度表示一定的数量,根据数量的多少画成长短不同的直条.带误差的条形图可以通过误差线来判断显著性. 继续使用我们的汽车销售数据(公众号回复:汽车销售,可以获得该数据)来演示,先导入 ...
- Python+Matplotlib绘制带误差线的柱状图
推荐图书: <Python程序设计(第3版)>,(ISBN:978-7-302-55083-9),董付国,清华大学出版社,2020年6月第1次印刷,2021年12月第11次印刷,山东省一流 ...
- python绘制有误差线的折线图
数据如上 import pandas as pd import numpy as np import matplotlib matplotlib.rcParams['backend'] = 'SVG' ...
- python绘制动态k线及均线,python : pyecharts 1.1.0 画K线图
pip install pyecharts ; 会安装 pyecharts-1.1.0 画K线图 kline1.py # coding: utf-8 import os, sys from pyech ...
- python 分布图_python数据分布型图表柱形分布图系列带误差线的柱形图
柱形分布图系列 柱形分布图系列 使用柱形图的方式展示数据的分布规律: 可以借助误差线或散点图: 带误差线的柱形图就是使用每个类别的均值作为柱形的高度: 再根据每个类别的标准差绘制误差线: 缺点:无法显 ...
最新文章
- R语言进行dataframe数据内连接(Inner join):使用R原生方法、data.table、dplyr等方案
- 数据结构为什么重要?
- 深入理解ext4等Linux文件系统
- POJ 2449 Remmarguts' Date(k短路模板)
- boost库在window下的编译
- NoSQL还是SQL?这一篇讲清楚
- bga焊盘怎么做_BGA封装的类型及焊盘设计的基本要求有哪些
- python批量删除注释_批量删除C和C++注释
- Python获取当前目录
- 使用srvany.exe把程序安装成windows服务的方法
- 官方教程:Apache Kylin和Superset集成,使用开源组件,完美打造OLAP系统
- 【GAN论文解读系列】NeurIPS 2016 InfoGAN 使用InfoGAN解耦出可解释的特征
- linux内核 精简 编译,精简LINUX内核配置及快速编译的方法收集
- 浙江大学计算机学院陈越教授,科学网—浙大教授陈越:快乐教学 行者无疆
- 002_simulink中显示模块中的名字
- 京东云擎 php,为什么我登陆京东云擎控制台会错误?
- 【TWVRP】基于matlab粒子群算法求解带时间窗的车辆路径规划问题(总成本最低)【含Matlab源码 2590期】
- 如何去掉抖音短视频水印----全网最好用的去抖音视频水印方法
- MTK虚拟sensor梳理
- 可视化文本处理模板代码