1、自变量的误差条

代码

import numpy as np
import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = 'SimHei' # 使图形中的中文正常编码显示
plt.rcParams['axes.unicode_minus'] = False # 使坐标轴刻度表签正常显示正负号 # 生成数据
x = np.arange(17)
error = np.random.rand(17)
y = np.power(x, 2) # 设置画板属性
plt.figure('百里希文', facecolor='lightyellow') # 绘制图形
plt.plot(x, y, 'gs--', mfc='y')
plt.errorbar(x, y, fmt='None', xerr=error, ecolor='r') # 增加图形元素
plt.xlabel('x')
plt.ylabel('x 的平方')
plt.grid(1, axis='both') plt.show()

图形

2、应变量的误差条

代码

import numpy as np
import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = 'SimHei' # 使图形中的中文正常编码显示
plt.rcParams['axes.unicode_minus'] = False # 使坐标轴刻度表签正常显示正负号 # 生成数据
x = np.arange(17)
error = np.random.rand(17)
y = np.sqrt(x) # 设置画板属性
plt.figure('百里希文', facecolor='lightyellow') # 绘制图形
plt.plot(x, y, 'yd--', mfc='g')
plt.errorbar(x, y, fmt='None', yerr=error, ecolor='r') # 增加图形元素
plt.xlabel('x')
plt.ylabel('x 的平方根')
plt.grid(1, axis='both') plt.show()

图形

3 、混合图形

代码

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = 'SimHei' # 使图形中的中文正常编码显示
plt.rcParams['axes.unicode_minus'] = False # 使坐标轴刻度表签正常显示正负号 # 生成数据
x = np.arange(17)
error = np.random.rand(17)
y1 =np.power(x, 2)
y2 = np.sqrt(x) # 设置画板属性
plt.figure('百里希文', facecolor='lightyellow') # 在第一个坐标系绘制图形
ax = plt.gca()
ax.plot(x, y1, 'yd--', mfc='g')
ax.errorbar(x, y1, fmt='None', yerr=error, xerr=error, ecolor='r', marker='d')
ax.set_ylabel('x 的平方根')
ax.set_xlabel('x')
ax.xaxis.grid(1, 'both')
ax.yaxis.grid(1, 'both') # 添加第二个 y 轴, 在第二坐标系绘图
ax2 = ax.twinx()
ax2.plot(x, y2, 'gh-.', mfc='y')
ax2.errorbar(x, y2, fmt='None', yerr=error, xerr=error, ecolor='r')
ax2.set_ylabel('x 的平方根根') plt.show()

图形

。。。。

Matplotlib 绘制误差条图的更多相关文章

  1. 【转】使用Python matplotlib绘制股票走势图

    转载出处 一.前言 matplotlib[1]是著名的python绘图库,它提供了一整套绘图API,十分适合交互式绘图.本人在工作过程中涉及到股票数据的处理如绘制K线等,因此将matplotlib的使 ...

  2. Python学习(一) —— matplotlib绘制三维轨迹图

    在研究SLAM时常常需要对其输出的位姿进行复现以检测算法效果,在ubuntu系统中使用Python可以很好的完成相关的工作. 一. Ubuntu下Python的使用 在Ubuntu下使用Python有 ...

  3. matplotlib 绘制多个图——两种方法

    import numpy as np import matplotlib.pyplot as plt #创建自变量数bai组du x= np.linspace(0,2*np.pi,500) #创建函数 ...

  4. 使用matplotlib绘制多轴图

    一个绘图对象(figure)可以包含多个轴(axis),在Matplotlib中用轴表示一个绘图区域,可以将其理解为子图.上面的第一个例子中,绘图对象只包括一个轴,因此只显示了一个轴(子图).我们可以 ...

  5. R语言与医学统计图形-【12】ggplot2几何对象之条图

    ggplot2绘图系统--几何对象之条图(包括误差条图) 1.条图 格式: geom_bar(mapping = , data = , stat = 'count', #统计变换默认计数 positi ...

  6. 用matplotlib绘制带误差的条形图及中英文字体设置

    #!/usr/bin/env python3 ## 以下是一个带误差条的条形图的例子,演示了误差条形图的绘制及中英文字体设置 import numpy as np import matplotlib ...

  7. 1 matplotlib绘制折线图

    from matplotlib import pyplot as plt #设置图形大小 plt.figure(figsize=(20,8),dpi=80) plt.plot(x,y,color=&q ...

  8. python使用matplotlib在一个图形中绘制多个子图以及一个子图中绘制多条动态折线问题

    在讲解绘制多个子图之前先简单了解一下使用matplotlib绘制一个图,导入绘图所需库matplotlib并创建一个等间隔的列表x,将[0,2*pi]等分为50等份,绘制函数sin(x).当没有给定x ...

  9. python使用matplotlib绘制折线图教程

    Matplotlib是一个Python工具箱,用于科学计算的数据可视化.借助它,Python可以绘制如Matlab和Octave多种多样的数据图形.下面这篇文章主要介绍了python使用matplot ...

随机推荐

  1. C——letterCounter

    /* 一个统计字母(含大小写)出现次数的C程序 */ #include <stdio.h> int main() { ]; char ch; /* initialization */ ; ...

  2. Spring 中的异常处理

    工作中遇到这样的同事,问他活干完吗,他说开发好了,结果测试时发现各种异常情况未处理,联调测试时各种未知错误,最后联调完成比他预期的两倍工作量还多.这样的开发如果是新人还可以原谅,如果有工作经验且出现多 ...

  3. [THUPC2018]生生不息(???)

    SB题,写来放松身心. 首先 $n,m\le 5$,这是可以打表的. 本地怎么对于一个 $n,m$ 求答案?此时虽然复杂度不需要太优,但是还是得够快. 一个想法是枚举每个初始状态,不停模拟.因为总状态 ...

  4. 图论问题(2) : hdu 1102

    题目转自hdu 1102,题目传送门 题目大意: 输入一个n*n的邻接矩阵,其中i行j列代表从i到j的路径的长度 然后又m条路已经帮你修好了,求最短要修多长的路才能使所有村庄连接 不难看出,这道题就是 ...

  5. [LeetCode] 767. Reorganize String 重构字符串

    Given a string S, check if the letters can be rearranged so that two characters that are adjacent to ...

  6. [LeetCode] 592. Fraction Addition and Subtraction 分数加减法

    Given a string representing an expression of fraction addition and subtraction, you need to return t ...

  7. cefsharp参考笔记

    https://blog.csdn.net/yh0503/article/details/86678115 https://blog.csdn.net/qq_17351077/article/deta ...

  8. SpringBoot第三篇:配置文件详解二

    作者:追梦1819 原文:https://www.cnblogs.com/yanfei1819/p/10615605.html 版权声明:本文为博主原创文章,转载请附上博文链接! 前言   本文主要讲 ...

  9. 查看linux中某个端口port是否被利用

    (1)lsof -i:端口号查看某个端口是否被占用 (2)netstat -an|grep 80 netstat -- show network status (3)杀掉进程 kill pid 注意: ...

  10. Let's Encrypt之acme.sh

    前言 Let's Encrypt 是一个证书颁发机构(CA).是由互联网安全研究小组(ISRG,Internet Security Research Group)主导并开发的一个新型数字证书认证机构( ...