Matplotlib之Bar Chart:

  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. data = [[300, 200, 250, 150, 280],
  5. [300, 166, 203, 250, 225],
  6. [100, 110, 115, 150, 112],
  7. [300, 200, 250, 150, 280],
  8. [20, 30, 15, 10, 12],
  9. [20, 10, 10, 10, 20]]
  10.  
  11. columns = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday')
  12. rows = [x for x in ("EQP.NY", "EQB.NY", "EQP.LN", "EQB.LN", "FIP.NY", "FIB.NY")]
  13.  
  14. values = np.arange(0, 2000, 500)
  15.  
  16. # Get some pastel shades for the colors
  17. colors = plt.cm.YlOrRd(np.linspace(0, 0.7, len(rows)))
  18.  
  19. n_rows = len(data)
  20.  
  21. index = np.arange(len(columns)) + 0.3
  22. bar_width = 0.4
  23.  
  24. # Initialize the vertical-offset for the stacked bar chart.
  25. y_offset = np.zeros(len(columns))
  26.  
  27. # Plot bars and create text labels for the table
  28. cell_text = []
  29. for row in range(n_rows):
  30. plt.bar(index, data[row], bar_width, bottom=y_offset, color=colors[row])
  31. y_offset = y_offset + data[row]
  32. cell_text.append(['%u' % x for x in data[row]])
  33. # Reverse colors and text labels to display the last value at the top.
  34. colors = colors[::-1]
  35. cell_text.reverse()
  36. # print(cell_text)
  37.  
  38. # Add a table at the bottom of the axes
  39. the_table = plt.table(cellText=cell_text,
  40. rowLabels=rows[::-1],
  41. rowColours=colors,
  42. colLabels=columns,
  43. loc='bottom')
  44.  
  45. # Adjust layout to make room for the table:
  46. plt.subplots_adjust(left=0.2, bottom=0.25)
  47.  
  48. # plt.ylabel("Loss in ${0}'s".format(value_increment))
  49. plt.ylabel('Break counts')
  50. # print(values)
  51. plt.yticks(values, ['%d' % val for val in values])
  52. plt.xticks([])
  53. plt.title('Break Recon Summary')
  54.  
  55. plt.show()

效果:

Matplotlib之Bar Chart的更多相关文章

  1. matplotlib 柱状图 Bar Chart 样例及参数

    def bar_chart_generator():     l = [1,2,3,4,5]     h = [20, 14, 38, 27, 9]     w = [0.1, 0.2, 0.3, 0 ...

  2. Bar Chart of Frequency of modals in different sections of the Brown Corpus

    Natural Language Processing with Python Chapter 4.8 colors = 'rgbcmyk' # red, green, blue, cyan, mag ...

  3. Highcharts - Bar Chart & Column Chart

    1. 条形图(Bar Chart)需要的数据格式类型如下: ["Luke Skywalker", "Darth Vader", "Yoda" ...

  4. Relative-Frequency|frequency|pie chart |bar chart

    2.2Organizing Qualitative Data The number of times a particular distinct value occurs is called its ...

  5. bubble chart|Matrix Scatter|Overlay Scatter|Scatterplots|drop-line|box plot|Stem-and-leaf plot|Histogram|Bar chart|Pareto chart|Pie chart|doughnut chart|

    应用统计学 对类别数据要分类处理: Bar chart复式条形图便于对比: Pareto chart:对类别变量依据频数高低排列: Pie chart:饼图用于一个样本,可以区分类别数据 doughn ...

  6. Matplotlib学习---用matplotlib画柱形图,堆积柱形图,横向柱形图(bar chart)

    这里利用Nathan Yau所著的<鲜活的数据:数据可视化指南>一书中的数据,学习画图. 数据地址:http://datasets.flowingdata.com/hot-dog-cont ...

  7. 转 HighCharts笔记之: Bar Chart

    最近需要做一些Web图标,研究了几个开源的第三方工具后,最后决定使用HighCharts开发: Highcharts 是一个用纯JavaScript编写的一个图表库, 能够很简单便捷的在web网站或是 ...

  8. plot bar chart using python

    Example import matplotlib.pyplot as plt import plotly.plotly as py # Learn about API authentication ...

  9. Bar Chart _Study

    ---恢复内容开始--- 以“3D BarChart”为例. 1.Select a theme.(选择一个主题模板) 2.Set up categories and groups.(设置类型和组) 3 ...

随机推荐

  1. Badboy - 导出脚本,用于JMeter性能测试

    参考: http://leafwf.blog.51cto.com/872759/1131119 http://www.51testing.com/html/00/130600-1367743.html ...

  2. ccpc网赛 hdu6705 path(队列模拟 贪心

    http://acm.hdu.edu.cn/showproblem.php?pid=6705 这是比赛前8题过的人数第二少的题,于是就来补了,但感觉并不难啊..(怕不是签到难度 题意:给个图,给几条路 ...

  3. codeforces 19 D. Points(线段树+set二分)

    题目链接:http://codeforces.com/contest/19/problem/D 题意:给出3种操作:1)添加点(x,y),2)删除点(x,y),3)查询离(x,y)最近的右上方的点. ...

  4. 面向微服务的体系结构评审中需要问的三个问题-咖啡杂谈:Java、新闻、故事和观点

    面向微服务的体系结构如今风靡全球.这是因为更快的部署节奏和更低的成本是面向微服务的体系结构的基本承诺. 然而,对于大多数试水的公司来说,开发活动更多的是将现有的单块应用程序转换为面向微服务的体系结构, ...

  5. (六十四)c#Winform自定义控件-温度计(工业)

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  6. 012 模块1-turtle库的使用

    目录 一.概述 二.turtle库基本介绍 2.1 turtle库概述 2.2 标准库 2.3 turtle的原(wan)理(fa) 2.4 turtle的魅力 三.turtle绘图窗体布局 3.1 ...

  7. Invalid bound statement(not found):cn.e3mall.mapper.TbItemMapper.selectByExample.....

    1.出现如下问题: 说明mapper接口和mapper.xml映射文件没有在一个文件夹下面 2.解决方法: 在dao层的pom.xml中配置一下: <!-- 如果不添加此节点mybatis的ma ...

  8. 基于Python的多线程与多进程

    1.I/O密集型与计算密集型 多进程适用于I/O密集型 多进程适用于计算密集型 2.没有sleep(T)的多个死循环只能用多进程 3.模块介绍: 1)threading模块(_thread模块已淘汰) ...

  9. Flink入门宝典(详细截图版)

    本文基于java构建Flink1.9版本入门程序,需要Maven 3.0.4 和 Java 8 以上版本.需要安装Netcat进行简单调试. 这里简述安装过程,并使用IDEA进行开发一个简单流处理程序 ...

  10. 【学习笔记】第一章 python安全开发简介

    1.1为什么黑客喜欢用python? python为我们提供了非常完善的基础代码库,覆盖了网络.文件.GUI.数据库.文本等大量内容,被形象的称为“”内置电池“”,用python开发,许多功能不必从零 ...