python数据可视化之matplotlib
来源:互联网 发布:美工字体整合打包下载 编辑:程序博客网 时间:2024/05/21 18:13
用matplotlib进行数据可视化探索
一.柱状图
import matplotlib.pyplot as pltimport matplotlibimport pandas as pdimport numpy as np
def bar_plot(): """ bar plot """ # 生成测试数据 means_men = (20, 35, 30, 35, 27) means_women = (25, 32, 34, 20, 25) # 设置标题 plt.title("title") # 设置相关参数 index = np.arange(len(means_men)) #横坐标 bar_width = 0.35 #宽度 # 画柱状图 plt.bar(index, means_men, width=bar_width, alpha=0.2, color="b", label="boy") #alpha是透明度 plt.bar(index+bar_width, means_women, width=bar_width, alpha=0.8, color="r", label="girl") #加上bar_width是为了并列放置,否则会堆在一起 plt.legend(loc="upper center", shadow=True) #设置图例位置 # 设置柱状图标示,上面的数字 for x, y in zip(index, means_men): plt.text(x, y+0.5, y, ha="center", va="bottom") #ha是水平对齐,va是垂直对齐 for x, y in zip(index, means_women): plt.text(x+bar_width, y+0.5, y, ha="center", va="bottom") # 设置刻度范围/坐标轴名称等 plt.ylim(0, 50) plt.xlabel("Group") plt.ylabel("Scores") plt.xticks(index+(bar_width/2), ("A", "B", "C", "D", "E")) # 图形显示 plt.show() returnbar_plot()
阅读全文
0 0
- 数据可视化-Python之Matplotlib
- python数据可视化之matplotlib
- python数据分析之数据可视化matplotlib
- Python数据可视化之Matplotlib学习笔记
- Python之数据可视化神奇-Matplotlib
- Python数据可视化之Matplotlib基础
- 【数据可视化】 之 Matplotlib
- matplotlib数据可视化入门-python
- Python数据可视化(matplotlib库)
- python—matplotlib数据可视化实例注解系列-----之横条图
- python—matplotlib数据可视化实例注解系列-----之箱状图
- python—matplotlib数据可视化实例注解系列-----之柱状图
- 读书笔记-python,数据可视化之matplotlib简单实用
- Python科学计算数据可视化模块-Matplotlib
- Python数据可视化—matplotlib笔记
- Python数据可视化—matplotlib笔记
- 【干货】Python使用matplotlib实现数据可视化
- python数据可视化-matplotlib库初体验
- Blockchain的鱼和熊掌系列(20) 之 pow 简单测试
- 前后端分离开发中处理跨域问题汇总
- jupyter notebook报错解决:不理解“open location”信息。 (-1708) Mac,jupyter不能自动打开浏览器
- 栈的压入、弹出序列
- java 遍历arrayList的四种方法
- python数据可视化之matplotlib
- 项目上传
- 利用大白菜u盘重装win7
- 检测ANR
- 十二居-AR导览公司,美景即刻站起来!
- 创建表空间 创建用户 授权 解锁 查询等
- git如何实现增量上线 实现前端资源增量式更新的一种思路
- 有关logcat-b radio过滤的问题
- Window.open()方法参数详解