当前位置:网站首页>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
边栏推荐
- /Can etc / shadow be cracked?
- Yarn resource scheduler
- 【leetcode】199.二叉树的右视图
- Detailed explanation of MapReduce calculation process
- Leetcode22: bracket generation
- 202. Happy number
- 24. Exchange the nodes in the linked list (linked list)
- 精彩回顾|「源」来如此 第六期 - 开源经济与产业投资
- 997. Square of ordered array (array)
- 第六站神京门户-------手机号码的转换
猜你喜欢

【leetcode】102. Sequence traversal of binary tree

Ueditor -- limitation of 4m size of image upload component

《Neo4j权威指南》简介,求伯君、周鸿袆、胡晓峰、周涛等大咖隆重推荐

Learning Notes 6 - Summary of several deep learning convolutional neural networks
![[provincial election joint examination 2022 d2t1] card (state compression DP, FWT convolution)](/img/e4/3c47edbc3241ba86f10a1ac8a963fd.png)
[provincial election joint examination 2022 d2t1] card (state compression DP, FWT convolution)

Solution architect's small bag - 5 types of architecture diagrams

Net start MySQL MySQL service is starting MySQL service failed to start. The service did not report any errors.

How can swagger2 custom parameter annotations not be displayed

【leetcode】107.二叉树的层序遍历II

精彩回顾|「源」来如此 第六期 - 开源经济与产业投资
随机推荐
UDP basic learning
Solutions to common problems in visualization (VIII) solutions to problems in shared drawing area
Esp32 learning - use and configuration of GPIO
Introduction to data analysis 𞓜 kaggle Titanic mission (IV) - > data cleaning and feature processing
SSH利用私钥无密钥连接服务器踩坑实录
Yarn core parameter configuration
精彩回顾|「源」来如此 第六期 - 开源经济与产业投资
Read integrity monitoring techniques for vision navigation systems
MySql常用语句
How to bind a process to a specified CPU
Source insight 4.0 FAQs
Can Jerry's AES 256bit [chapter]
全栈交叉编译X86完成过程经验分享
Learning notes 7-depth neural network optimization
Problems of class in C # and database connection
203、移出链表元素(链表)
SQL Server cursor circular table data
[Niuke challenge 47] C. conditions (BitSet acceleration Floyd)
第六站神京门户-------手机号码的转换
The difference between restful and soap