当前位置:网站首页>Visual common drawing (IV) histogram
Visual common drawing (IV) histogram
2022-04-23 10:54:00 【The big pig of the little pig family】
Visualizing common drawings ( Four ) Histogram
One . Introduction to histogram
Basic histogram , Use vertical or horizontal columns to show numerical comparisons between categories . One axis represents the classification dimension to be compared , The other axis represents the corresponding value .
A histogram is different from a histogram , The histogram can't show the continuous change trend of data in an interval . The histogram describes the classified data , The answer is in each category 【 How many? ?】 This problem . It should be noted that , When the histogram shows a lot of categories, it will lead to display problems such as cascade of category names .
Two . The composition of the histogram
The bar chart includes at least the following parts :
- Horizontal axis category
- Number of longitudinal axes / The number
- graphics
- legend
3、 ... and . Use scenarios
Data used : A category field , A numeric field .
The main function : Compare the numerical size of classified data .
Number of data : No more than 30 Data .
Applicable scenario :
- It is suitable for classification data comparison .
Not applicable to the scene :
- When there are too many data categories .
- When you want to show data trends .
Four . Realization
stay matplotlib Use in bar
Function to draw a histogram , For a detailed introduction of the function and the annotation of the histogram, see the links below .
notes :
Take the following table as an example to draw the histogram
genre( The game type ) | sold( Sales volume ) |
---|---|
Sports | 27,500 |
Strategy | 11,500 |
Action | 6,000 |
Shooter | 3,500 |
Other | 1,500 |
The complete program code is as follows :
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] # Settings support Chinese
plt.rcParams['axes.unicode_minus'] = False # Set up - Number
plt.style.use('ggplot')
genre = ["Sports", "Strategy", "Action", "Shooter", "Other"]
sold = [27500, 11500, 6000, 3500, 1500]
patches = plt.bar(range(len(sold)), sold, width=0.5, color=['red', 'green', 'blue', "cyan", "olive"])
plt.bar_label(patches)
plt.xticks(range(len(sold)), genre, fontsize=15)
plt.xlabel(" Types of games ", fontsize=20)
plt.ylabel(" sales ( individual )", fontsize=20)
plt.title("2021 Comparison of annual game sales ", fontsize=25, fontweight="bold")
plt.grid()
plt.legend(patches, genre, fontsize=15)
plt.show()
The results are as follows :
5、 ... and . Reference resources
版权声明
本文为[The big pig of the little pig family]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230617063326.html
边栏推荐
- 图像处理——噪声小记
- Solutions to common problems in visualization (VIII) solutions to problems in shared drawing area
- 解决方案架构师的小锦囊 - 架构图的 5 种类型
- SQL Server 游标循环表数据
- SQL Server recursive query of superior and subordinate
- MySQL how to merge the same data in the same table
- SQL server query database deadlock
- 微信小程序中app.js文件、组件、api
- How to quickly download vscode
- Yarn resource scheduler
猜你喜欢
【leetcode】102.二叉树的层序遍历
得到知识服务app原型设计比较与实践
Swagger2 自定义参数注解如何不显示
Yarn core parameter configuration
C language - custom type
VIM + ctags + cscope development environment construction guide
How to quickly download vscode
Intuitive understanding entropy
Comparison and practice of prototype design of knowledge service app
Initial exploration of NVIDIA's latest 3D reconstruction technology instant NGP
随机推荐
Swagger2 接口如何导入Postman
Let the LAN group use the remote device
VIM usage
RESTful和SOAP的区别
Comparison and practice of prototype design of knowledge service app
59、螺旋矩阵(数组)
How to bind a process to a specified CPU
Diary of dishes | Blue Bridge Cup - hexadecimal to octal (hand torn version) with hexadecimal conversion notes
How does the swagger2 interface import postman
How can swagger2 custom parameter annotations not be displayed
Chapter 1 of technical Xiaobai (express yourself)
SQL Server 递归查询上下级
SQL server query database deadlock
MySQL common statements
SSH利用私钥无密钥连接服务器踩坑实录
全栈交叉编译X86完成过程经验分享
349、两个数组的交集
全栈交叉编译X86完成过程经验分享
Esp32 learning - add folder to project
Qinglong panel pull library command update [April 20, 2022] collection is not lost