matplotlib系列——条形图
import matplotlib.pyplot as plt
import numpy as np
import matplotlib x = ["战狼2","激情8","功夫瑜伽","西游伏妖","变形金刚","摔跤吧"]
y = [56.01,26.94,17.53,16.49,15.45,12.96]
# 设置图形对象 :窗口
plt.figure('Figure Object 1', # 图形对象名称 窗口左上角显示
figsize = (8, 5), # 窗口大小
dpi = 120, # 分辨率
facecolor = 'white', # 背景色
) #绘制条形图
"""
left:长条形中点横坐标
height:长条形高度
width:长条形宽度,默认值0.8
label:为后面设置legend准备
"""
rects1=plt.bar(x, y, width=0.4,label='Jacobi',alpha=0.8,color='orange')
#rects1=plt.bar(x, y, width=0.4,label='Jacobi',alpha=0.8,color='orange') #横向条形图 #刻度
plt.xticks(range(len(x)),x,rotation=90,fontproperties='SimHei',fontsize=8)
#plt.yticks(range(len(x)), x, rotation=90) #条形图高度的标注
for rect in rects1:
height = rect.get_height()
plt.text(rect.get_x() + rect.get_width()/2, height+1, height, ha="center", va="bottom",fontsize=7) #坐标轴范围
plt.xlim(-1,len(x)+1)
plt.ylim(0, max(y)*1.2) #显示图例
plt.legend() #坐标轴标注
#plt.xlabel("X轴",fontproperties='SimHei',fontsize=8)
plt.ylabel("Y轴",fontproperties='SimHei',fontsize=10) #标题
plt.title('电影票房',fontproperties='SimHei',fontsize=12) plt.show()

matplotlib系列——条形图的更多相关文章
- matplotlib系列——线的属性
幕布视图:https://mubu.com/doc/alG8r_3iSw 参考文献:嵩天的Python课程讲义 示例(更多示例:matplotlib系列——折线图) 效果 颜色 线的风格 标记类型 ...
- python matplotlib.pyplot 条形图详解
python matplotlib.pyplot 条形图详解 一.创建直方图 可以用bar函数来创建直方图 然后用show函数显示直方图 比如: import matplotlib.pyplot as ...
- 4.4Python数据处理篇之Matplotlib系列(四)---plt.bar()与plt.barh条形图
目录 目录 前言 (一)竖值条形图 (二)水平条形图 1.使用bar()绘制: 2.使用barh()绘制: (三)复杂的条形图 1.并列条形图: 2.叠加条形图: 3.添加图例于数据标签的条形图: 目 ...
- python Matplotlib 系列教程(三)——绘制直方图和条形图
在本章节我们将学习如何绘制条形图和直方图 条形图与直方图的区别:首先,条形图是用条形的长度表示各类别频数的多少,其宽度(表示类别)则是固定的: 直方图是用面积表示各组频数的多少,矩形的高度表示每一组的 ...
- Matplotlib系列(四)--plt.bar与plt.barh条形图
(一)竖条条形图 参数说明 参数 说明 类型 x x坐标 int,float height 条形的高度 int,float width 线条的宽度 0~1,默认是0.8 botton 条形的起始位置 ...
- 4.7Python数据处理篇之Matplotlib系列(七)---matplotlib原理分析
目录 目录 前言 (一)总框架分析 (二)函数式的绘图 1.说明: 2.函数绘图的缺优点 3.绘图类的函数 4.操作类的函数 5.例子: (三)面向对象式的绘图 1.基本概念 2.基本对象 3.面向对 ...
- Python 绘图与可视化 matplotlib 动态条形图 bar
bar的参考链接:https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.bar.html 第一种办法 一种方法是每次都重新画,包括清除f ...
- 3.matplotlib绘制条形图
plt.bar() # coding=utf-8 from matplotlib import pyplot as plt from matplotlib import font_manager my ...
- matplotlib之条形图
1.知识点 1.plt.figure(figsize=(20,8),dpi=80)设置图像大小,主要参数为figsize(a,b) 2.plt.barh(range(len(a)),b,height= ...
随机推荐
- NGUI的sprite的使用(九宫切图)
一,图集的添加和背景图的选择 图集的选择Atlas和背景图的选择Sprite 二,type的sliced切背景图的使用 当选择Sprite后的edit时,我们就可以设置当前背景图的边距,也有切图的意思 ...
- 汇编语言之寄存器使用bx si di bp
转载自:https://www.cnblogs.com/youxin/archive/2012/05/29/2524780.html 如果你看到这篇博客时正在做第七章问题,强烈建议先去把8.1~8.4 ...
- 安卓构架组件——概述 Android Architecture Components
谷歌官文文档地址:https://developer.android.google.cn/topic/libraries/architecture 安卓构架组建是库的集合:帮助你设计健壮的.易测试的. ...
- "Unable to locate package lrzsz"的解决办法
某天安装一些常用软件,比如lrzsz的时候出错了 $ sudo apt-get install lrzsz Reading package lists... Done Building depende ...
- Spring事务中的readonly
来源:https://www.cnblogs.com/straybirds/p/9147892.html Spring的事务经常会有这样的配置: <tx:method name="se ...
- SpringBoot中Redis的使用
转载:http://www.ityouknow.com/springboot/2016/03/06/spring-boot-redis.html Spring Boot 对常用的数据库支持外,对 No ...
- 并行流水线--求 (B+C)*B/2
public class Msg { public double i; public double j; public String orgStr = null; } import java.util ...
- 【leetcode】1020. Partition Array Into Three Parts With Equal Sum
题目如下: Given an array A of integers, return true if and only if we can partition the array into three ...
- k-近邻算法(kNN)测试算法:作为完整程序验证分类器
#测试算法:作为完整程序验证分类器 def datingClassTest(): hoRatio = 0.10 #设置测试集比重,前10%作为测试集,后90%作为训练集 datingDataMat,d ...
- AcWing 252. 树 (点分治)打卡
题目:https://www.acwing.com/problem/content/254/ 题意:求一棵树上,路径<=k的有多少条 思路:点分治,我们用两个指针算solve函数,首先对算出来的 ...