当前位置:网站首页>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
边栏推荐
- Dirichlet prefix sum (number theory optimization formula sub complexity weapon)
- 142. Circular linked list||
- 【leetcode】102. Sequence traversal of binary tree
- 209、长度最小的子数组(数组)
- How to bind a process to a specified CPU
- Idea - indexing or scanning files to index every time you start
- 997、有序数组的平方(数组)
- 24、两两交换链表中的节点(链表)
- Embedded related surface (I)
- Pytorch implementation of transformer
猜你喜欢

Example of pop-up task progress bar function based on pyqt5

SQL Server recursive query of superior and subordinate

【leetcode】199. Right view of binary tree

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

MySQL how to merge the same data in the same table

mysql同一个表中相同数据怎么合并

得到知识服务app原型设计比较与实践
MapReduce core and foundation demo

Six practices of Windows operating system security attack and defense

SSH uses private key to connect to server without key
随机推荐
Derivation and regularization
ID number verification system based on visual structure - Raspberry implementation
Pytorch implementation of transformer
链表相交(链表)
Detailed explanation of MapReduce calculation process
Chapter 1 of technical Xiaobai (express yourself)
Deploy jar package
mysql同一个表中相同数据怎么合并
Swagger2 接口如何导入Postman
206. Reverse linked list (linked list)
How to Ping Baidu development board
[Niuke challenge 47] C. conditions (BitSet acceleration Floyd)
RESTful和SOAP的区别
707. Design linked list (linked list)
Precautions for latex formula
707、设计链表(链表)
Define linked list (linked list)
Notes on concurrent programming of vegetables (V) thread safety and lock solution
242、有效字母异位词(哈希表)
Arbitrary file reading vulnerability exploitation Guide