python数据分析-柱状图绘制及常用参数设置
2020-03-25 07:32
579 查看
linux+pycharm+anaconda
#柱形图绘制与参数设置 #plt.bar(x,height,width,bottom,align,color,edgecolor) """ X 表示在什么位置显示柱形图 height 表示每根柱子的高度 width 表示每根柱子的宽度,每根柱子的宽度可以都一样,也可以各不相同 bottom 表示每根柱子的底部位置,每根柱子的底部位置可以都一样,也可以各不相同. align 表示柱子的位置与x值的关系,有center,edge 两个参数可选,center表示柱子位于x值的中心位置,edge 表示柱子位于x值的边缘位置 color柱子颜色 edgecolor 表示柱子边缘的颜色 """ import matplotlib.pyplot as plt import numpy as np #建立一个坐标系 plt.subplot (1, 1,1) #指明x和y值 x = np.array(["East Area","North Area","South Area","West Area"]) y = np.array([ 8566,6482,5335,7310]) #绘图 plt. bar (x, y, width=0.5,align="center", label="Task quantity") #设置标题 plt.title("Tasks of all regions in the country",loc= "center") #添加数据标签 for a,b in zip(x,y) : plt. text (a,b,b,ha='center', va= "bottom", fontsize=12) #设置x轴和y轴的名称 plt.xlabel('partition') plt.ylabel ('Task quantity') plt. legend() #显示图例 #保存图表到本地 #plt. savefig ("bar.jpg") plt.show()
成图效果
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- Python pandas数据分析中常用方法
- Python sklearn数据分析中常用方法
- Python数据分析与挖掘实战(Pandas,Matplotlib常用方法)
- Python数据分析:pandas常用函数
- Python数据分析常用函数笔记
- python数据分析-DataFrame数据框常用基本知识(列、行、切片、计算等code)
- [Python教程] Python SimpleITK软件包常用参数与使用方法分析
- Python日常办公小程序——读取并分析aTimeLogger输出的html文件,并使用matplotlib绘制柱状图
- python常用的数据分析工具包
- Python数据分析matplotlib设置多个子图的间距
- Python pandas数据分析中常用方法
- Python 数据分析之Pandas 常用指令
- Python数据分析:numpy常用函数
- Python数据分析之pandas.read_csv参数说明
- 学习笔记(16):Python数据分析与爬虫-Python爬虫:正则表达式中的常用模式字符串及两种匹配模式...
- Python 数据分析第二期--简述数据集常用格式及操作
- Python Matplotlib实现三维/四维数据的柱状图绘制
- Python Numpy数据分析中常用方法
- 用Python做数据分析:Pandas常用数据查询语法
- Python sklearn数据分析中常用方法