当前位置:网站首页>Visual common drawing (III) area map
Visual common drawing (III) area map
2022-04-23 10:53:00 【The big pig of the little pig family】
Area map
One . Introduction to area map
Area map is also called area map . It is formed on the basis of line chart , It fills the area between the line and the coordinate axis of the independent variable with color or texture , Such a filled area is called area , Color filling can better highlight the trend information .
It should be noted that the color should have a certain degree of transparency , Transparency can help users observe the overlapping relationship between different sequences , The transparency of different sequences can be reduced .
Like a line chart , Area maps are also used to emphasize the extent to which quantities change over time , It can also be used to arouse people's awareness of General trend Attention . They are most often used to show trends and relationships , Instead of conveying specific values .
Area maps are usually divided into two categories :
- General area map : All data starts from the same zero axis .
- Stacking area map : The starting point of each data set is different , All based on the previous data set . Used to display the trend line of the proportion of each value over time or category , Stacked area maps are particularly useful in showing the changes of the total component of big data .
- Percentage stacked area diagram : Used to display the trend line of the percentage of each value over time or category . The proportional trend line of each series can be emphasized .
Two . Composition of area map
The general area map consists of the following four parts :
- The horizontal axis : Time .
- The vertical axis : Represents the value .
- Line : Indicates the trend relationship between data .
- area : The filled area between the line and the axis .
3、 ... and . Use scenarios
Suitable data : Data of two consecutive fields .
The main function : Observe the change trend of the data .
Applicable scenarios :
- Show the values that change in the time dimension .
Scenarios that are not applicable :
- Numerical comparison between different classifications is not applicable .
Four . Realization
stay matplotlib Drawing an area map in requires two functions ,plot and fill_between .plot Used to draw polylines ,fill_between Used for area filling .fill_between The method is introduced as follows :
fill_between(x, y1, y2=0, where=None, interpolate=False, step=None, *,data=None, **kwargs)
Parameters 1:x: length N Array of , Execute the of the curve X Shaft span .
Parameters 2:y1: length N Array or scalar , Specify the first curve .
Parameters 3:y2: length N Array or scalar , Specify the second curve .( The default value is 0)
Parameters 4:where: The length is N An array of Boolean types , Specify the location of the fill .
Parameters 5:interpolate: Boolean type , Unknown .
Parameters 6:step: Qualified string : Specifies whether the fill uses a step function , Optional :
pre:y Values from each x The position continues to the left .post:y Values from each x The position continues to the right .mid: The step occurs at x In the middle of the position .
Parameters 7:**kwargs: The accepted keyword parameter is passed to the associated PolyCollection object .
Return value :PolyCollection object .
notes :
Implement complete code :
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.sans-serif'] = ['SimHei'] # Settings support Chinese
plt.rcParams['axes.unicode_minus'] = False # Set up - Number
plt.style.use('seaborn-notebook')
# Data set used
year = [1950, 1960, 1970, 1980, 1990, 2000, 2010, 2018]
asia_population = [1394, 1686, 2120, 2625, 3202, 3714, 4169, 4560]
y_label = np.arange(0, 5000, 500)
avg = np.average(asia_population)
plt.plot(asia_population, lw=3, color='k', label="Asia's population")
plt.hlines(avg, -5000, 5000, ls='--', label=f"average:{
avg}", color='red')
plt.fill_between(range(len(year)), asia_population, alpha=0.3)
plt.title(" Demographic changes in Asia (1950-2018)", fontsize=25, fontweight='bold')
plt.xlabel(" year ", fontsize=15)
plt.ylabel(" Population ( One million )", fontsize=15)
plt.xticks(range(len(year)), labels=year, fontsize=10)
plt.xlim([-0.5, len(year)-0.5])
plt.grid()
plt.legend(fontsize=15)
plt.show()
The effect is as follows :

5、 ... and . Reference resources
版权声明
本文为[The big pig of the little pig family]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230617063408.html
边栏推荐
- 707. Design linked list (linked list)
- ID number verification system based on visual structure - Raspberry implementation
- 454. Sum of four numbers (hash table)
- Latex usage
- 997. Square of ordered array (array)
- Chapter 120 SQL function round
- MapReduce core and foundation demo
- 202. Happy number
- 景联文科技—专业数据标注公司和智能数据标注平台
- Detailed explanation of MapReduce calculation process
猜你喜欢

Comparison and practice of prototype design of knowledge service app

Cve-2019-0708 vulnerability exploitation of secondary vocational network security 2022 national competition

Introduction to wechat applet, development history, advantages of applet, application account, development tools, initial knowledge of wxml file and wxss file

Chapter 120 SQL function round

Manjaro installation and configuration (vscode, wechat, beautification, input method)

【leetcode】199.二叉树的右视图

Notes on concurrent programming of vegetables (IX) asynchronous IO to realize concurrent crawler acceleration

SQL Server recursive query of superior and subordinate

JVM - common parameters

SSH利用私钥无密钥连接服务器踩坑实录
随机推荐
Wonderful review | deepnova x iceberg meetup online "building a real-time data Lake based on iceberg"
142. Circular linked list||
App. In wechat applet JS files, components, APIs
全栈交叉编译X86完成过程经验分享
Comparison and practice of prototype design of knowledge service app
Notes on concurrent programming of vegetables (IX) asynchronous IO to realize concurrent crawler acceleration
CentOS/Linux安装MySQL
部署jar包
997、有序数组的平方(数组)
206、反转链表(链表)
What are the system events of Jerry's [chapter]
SSH uses private key to connect to server without key
24、两两交换链表中的节点(链表)
【leetcode】199.二叉树的右视图
Xdotool key Wizard
SQL Server 游标循环表数据
59、螺旋矩阵(数组)
How can swagger2 custom parameter annotations not be displayed
得到知识服务app原型设计比较与实践
Idea - indexing or scanning files to index every time you start