Barh函数--Matplotlib
函数Barh()–用于绘制条形图
本节的条形图绘制所用到的参数与上一节的柱形图的参数使用一致,本次不再做详细介绍,需要请查看bar函数链接: bar函数–绘制柱形图
Barh函数功能: Make a horizontal bar plot
绘制水平条形图
The bars are positioned at y with the given alignment. Their dimensions are given by width and height. The horizontal baseline is left (default 0).Many parameters can take either a single value applying to all bars or a sequence of values, one for each bar.
这些条块Bar以给定的对齐方式放在y处。他们的大小通过指定的宽度和高度确定。水平基线在左侧(默认0)。许多参数可以采用两种方式赋值:一是对所有条块赋予同一个值;二是传入一系列值,每个条块一个单独的值。
函数语法:
barh(y, width, height=0.8, left=None, *, align=‘center’, **kwargs)
函数参数:
y: float or array-like.The y coordinates of the bars. See also align for the alignment of the bars to the coordinates.
浮点型或类数组对象;条形的y轴坐标。另请参见‘align’参数了解柱与坐标的对齐方式
width: float or array-like.The width(s) of the bars.
浮点型或类数组对象;条形的宽度
height: float or array-like, default: 0.8.The heights of the bars.
浮点型或类数组对象;条形的高度,默认值0.8
left: float or array-like, default: 0.The x coordinates of the left sides of the bars.
浮点型或类数组对象;条块左侧的x坐标。
align:{‘center’, ‘edge’}, default: ‘center’.Alignment of the base to the y coordinates*:
对齐方式: 中间,边缘 ,默认为中间。条块底部与y轴坐标的对齐方式
‘center’: Center the bars on the y positions.
‘edge’: Align the bottom edges of the bars with the y positions.
To align the bars on the top edge pass a negative height and align=‘edge’.
中间:y坐标在条块左侧的中间位置
边缘:y坐标在条块左侧的底部位置
设置y坐标在条块左侧的顶部位置需要传入高度为负值同时对其方式为边缘
Other Parameters:
color: color or list of color, optional。The colors of the bar faces.
可选参数,颜色或颜色列表 。条块颜色
edgecolor: color or list of color, optional。The colors of the bar edges.
可选参数:颜色或颜色列表 。条块边缘的颜色
linewidth: float or array-like, optional。Width of the bar edge(s). If 0, don’t draw edges.
线条宽度:可选参数,浮点型或类数组 。条块边缘线的宽度,若值为0,则不绘制边线
tick_label: str or list of str, optional 。The tick labels of the bars. Default: None (Use default numeric labels.)
可选参数,字符串或字符串列表,条块的刻度线标签,默认:使用数字标签
**kwargs: Rectangle properties
其他关键参数: 定义矩形柱子的属性
绘制条形图:
使用align参数设置y轴坐标在条块左侧的底部
设置align在条块左侧上部时,需要同时设置height参数为负值且align为edge
设置参数left条块儿向右平移
参数leftleftleft默认值
参数left=3left=3left=3,条块儿向右平移距离3
参数leftleftleft为条块儿个数相等的数组,每个条块儿向右移动相应的距离
代码实现:
import matplotlib as mpl
import matplotlib.pyplot as pltmpl.rcParams['font.sans-serif'] = ['SimHei']
mpl.rcParams['axes.unicode_minus'] = Falsex = [3, 2, 3, 4, 5, 6, 7, 8]
y = [3, 1, 4, 5, 8, 9, 7, 2]plt.barh(x, y, tick_label=['q', 'a', 'c', 'e', 'r', 'j', 'b', 'p'],color=['brown'], align='center', hatch='/')plt.title('条形图')plt.xlabel('箱子重量(Kg)')
plt.ylabel('箱子编号')plt.show()
Barh函数--Matplotlib相关推荐
- python使用matplotlib可视化条形图、使用barh函数可视化条形图(使用barh函数可视化多分类的并行条形图、side by side)
python使用matplotlib可视化条形图.使用barh函数可视化条形图(使用barh函数可视化多分类的并行条形图.side by side) 目录
- Python Matplotlib绘制柱状图(bar和barh函数)详解
前言 本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,如有问题请及时联系我们以作处理. PS:如有需要Python学习资料的小伙伴可以加点击下方链接自行获取 python免费学习资 ...
- 【MATLAB】进阶绘图 ( Bar 条形图 | bar 函数 | bar3 函数 | Bar 条形图样式 | 堆叠条形图 | 水平条形图 | barh 函数 )
文章目录 一.Bar 条形图 1.bar 函数 2.矩阵数据表示 3.bar 函数代码示例 二.Bar 条形图样式 1.bar 函数样式 2.堆叠条形图示例 三.水平条形图 1.barh 函数 2.代 ...
- 魔法函数%matplotlib 解决matplotlib画图在Jupter/IPython中不显示
用Python画图时,有时候画图结果存储在内存中不显示,如下图 import seaborn as sns subset = tz_counts[:10] sns.barplot(y=subset.i ...
- subplots_adjust()函数--matplotlib
1. 函数功能 调整子区的展现效果 2. 函数语法 subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, ...
- setp函数--Matplotlib
函数功能: Set a property on an artist object. 设置元素属性 函数语法: setp(obj, *args, **kwargs) 函数参数: obj: 要设置的对象 ...
- xlabel函数--Matplotlib
xlabel函数使用–Matplotlib xlabel语法.功能与参数设置可平移至ylabel. 函数语法: xlabel(xlabel, fontdict=None, labelpad=None, ...
- annotate()函数--matplotlib
1. 函数功能 对点(x,y)添加带箭头的注释文本. 2. 函数语法 Axes.annotate(text, xy, xytext=None, xycoords='data', textcoords= ...
- 系统学习Python——2D绘图库Matplotlib:绘图函数matplotlib.pyplot.plot(plt.plot)
分类目录:<系统学习Python>总目录 matplotlib.pyplot是Matplotlib的基于状态的接口.它提供了一种隐式的.类似MATLAB的绘图方式.它还会在您的屏幕上打开图 ...
- python 绘制正弦余弦函数 matplotlib的基本使用
"""matplotlib的基本使用 """ import matplotlib.pyplot as mp import numpy as ...
最新文章
- Eclipse利用Maven的插件部署web项目到远程tomcat服务器
- 全北现代宣布江苏苏宁中后卫洪正好租借延长1年
- Anordighos手绘休闲脚本字体
- Struts2的配置文件struts.xml详解
- C语言之预处理探究(四):#、##和预定义宏
- Android View框架总结(一)
- JVM性能优化之JVM调优
- Java分页工具实现方法
- 一篇Chat(沉迷机器人操作系统(ROS)的一个理由和四种修仙秘籍)
- 批量插入图片到Excel中批注中,Excel插件 E灵
- qualcomm QSD MSM APQ区别
- iOS清除缓存功能开发
- win10系统怎样安装/更新独立显卡驱动
- matlab中四阶龙格库塔算法、欧拉算法和改进的欧拉算法的总结
- 【深度学习——BNN】:二值神经网络BNN——学习与总结
- 最强蜗牛换了手机找不到服务器,最强蜗牛怎么转服?更换服务器方法与条件说明[多图]...
- android studio夜间模式,android studio怎样实现夜间模式
- [OPENCV]010.深度神经网络(dnn模块)
- access字段相加_access如何对一行的几列求和
- 漫步奥格瑞玛 Portal Scene Manager
热门文章
- 扇贝有道180927每日一句
- Atitit java项目常用类库表 目录 1. Ati总的常用库	1 1.1. 表达式,语言解析类库	1 1.2. 字符串模板解析库velocity freemark	1 1.3. rest库
- paip.python错误解决2
- paip.invalid conversion from FormWdg* to SOCKET {aka unsigned int}
- paip.mysql 导入出错,提示语法错误.txt
- SQLServer2008客户端软件
- 美国数字货币牌照BitLicence中文版(全文翻译)
- 到底谁才是苹果公司实际控制人?
- (转)金丘股份CEO左鹏:用区块链做ABS,实现消费金融ABS创新
- 开源界也要封闭,OpenSource能否继续无国界 | 凌云时刻