[Python Study Notes]双层柱状图绘制
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>文件: 双层直方图.py
>>作者: liu yang
>>邮箱: liuyang0001@outlook.com
>>博客: www.cnblogs.com/liu66blog ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' #!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib
import matplotlib.pyplot as plt
# 指定字体,防止
font=matplotlib.font_manager.FontProperties(fname=r"C:\Windows\Fonts\Deng.ttf") # 双层直方图
def barsplot():
# 先生成一个画布
fig=plt.figure()
# 生成数据
x1=[x-0.2 for x in range(1,9)]
y1=[n*2 for n in range(1,9)]
x2=[x+0.2 for x in range(1,9)]
y2=[x**2 for x in x2]
# 开始画条形图1
l1=plt.bar(x1,y1,color='g',width=0.4)
# 开始画条形图2
l2=plt.bar(x2,y2,color='b',width=0.4)
# 显示画的图
plt.xlabel('x轴信息',fontproperties=font)
plt.ylabel('y轴信息',fontproperties=font)
plt.title('双层直方图',fontproperties=font)
plt.legend(handles = [l1, l2,], labels = ['去年', '今年'], loc = 'best',prop=font)
for x1,x2, y1, y2 in zip(x1,x2, y1, y2):
plt.text(x1 , y1, '%.0f' % y1, ha='center', va='bottom')
plt.text(x2 , y2, '%.0f' % y2, ha='center', va='bottom')
plt.show() # 如果最为主模块运行
if __name__ == '__main__':
# 实例化
ba=barsplot()
[Python Study Notes]双层柱状图绘制的更多相关文章
- [Python Study Notes]堆叠柱状图绘制
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...
- [Python Study Notes]水平柱状图绘制
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...
- [Python Study Notes]气泡散点图绘制
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...
- [Python Study Notes]七彩散点图绘制
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...
- [Python Study Notes]折线图绘制
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...
- [Python Study Notes]饼状图绘制
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...
- [Python Study Notes]匿名函数
Python 使用 lambda 来创建匿名函数. lambda这个名称来自于LISP,而LISP则是从lambda calculus(一种符号逻辑形式)取这个名称的.在Python中,lambda作 ...
- [Python Study Notes]字符串处理技巧(持续更新)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...
- [Python Study Notes]with的使用
在 Python 2.5 中, with 关键字被加入.它将常用的 try ... except ... finally ... 模式很方便的被复用.看一个最经典的例子: with open('fil ...
随机推荐
- mac实用脚本
安全清倒废纸篓(AppleScript) on run {input, parameters} set title to "安全清倒废纸篓" set trashIsEmptyMes ...
- SSM整合(spring、springMVC、mybatis)
需要用的包: 包括:spring的包.springMVC的包.mybatis的包.数据库驱动包.json相关的包 配置如下,首先是mybatis的配置 <?xml version="1 ...
- Disruptor_学习_00_资源帖
一.官方 disruptor-github disruptor-api LMAX Disruptor 二.精选资料 Disruptor入门-官方文档翻译-方腾飞 Disruptor官方文档实现 Dis ...
- Memorial for Nanjing victims today 南京大屠杀死难者公祭仪式今于南京举行 勿忘国耻,活捉小*日*本。
China will hold an annual memorial for the victims of the Nanjing Massacre today in the eastern city ...
- PhotoShop使用指南(3)—— 将多张图片添加到图层
第一步:选择文件菜单>脚本>将文件载入堆栈 第二步:点击浏览添加要批量载入的图片
- OpenCV那个版本的比较好用、稳定,参考资料也较多的
2.4.8.上opencv官网就能下载到,对应不同版本的VS有编译好的文件. 2.4以后的变化不大.所以你可以百度opencv,有中文网站,上面有详细的说明.如果是在windows系统的话,可以使用v ...
- mysql定时任务备份bat命令-记录一下待日后使用
最近有个任务,需要每日备份数据库到某个磁盘,使用window定时任务调用bat文件实现. %Date:~0,2%获取星期几,这个要根据系统进行尝试, 有 星期几 7/25/2018 有 2018/ ...
- linux下的第一个C程序及其编译方法
#include <stdio.h> #include <stdlib.h> int main(int argc, char ** argv) { printf(& ...
- 控制input框输入非数字
<input type="text" onkeyup="value=value.replace(/[^\d.]/g,'')">
- C# 读xml注释或过滤xml注释
有这么个需求: 要统计所有的配置文件,这些配置文件都xml格式,并把这些配置写到数据表里,如果有注释要把这些注释写到对应配置对象的描述字段上 <item id="" key= ...