当前位置:网站首页>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
边栏推荐
- Learning notes 7-depth neural network optimization
- Installing MySQL with CentOS / Linux
- 《Neo4j权威指南》简介,求伯君、周鸿袆、胡晓峰、周涛等大咖隆重推荐
- Solutions to common problems in visualization (VIII) solutions to problems in shared drawing area
- Chapter 1 of technical Xiaobai (express yourself)
- How to bind a process to a specified CPU
- Manjaro installation and configuration (vscode, wechat, beautification, input method)
- Linked list intersection (linked list)
- 图像处理——噪声小记
- 206. Reverse linked list (linked list)
猜你喜欢
精彩回顾|「源」来如此 第六期 - 开源经济与产业投资
Cve-2019-0708 vulnerability exploitation of secondary vocational network security 2022 national competition
第六站神京门户-------手机号码的转换
SQL Server 游标循环表数据
Intuitive understanding entropy
STM32接电机驱动,杜邦线供电,然后反烧问题
The courses bought at a high price are open! PHPer data sharing
【leetcode】199. Right view of binary tree
【leetcode】102. Sequence traversal of binary tree
SSH uses private key to connect to server without key
随机推荐
Xdotool key Wizard
二叉树的构建和遍历
Charles 功能介绍和使用教程
19、删除链表的倒数第N个节点(链表)
19. Delete the penultimate node of the linked list (linked list)
Manjaro installation and configuration (vscode, wechat, beautification, input method)
349、两个数组的交集
What are the system events of Jerry's [chapter]
RESTful和SOAP的区别
【leetcode】199. Right view of binary tree
VScode
206. Reverse linked list (linked list)
242. Valid Letter ectopic words (hash table)
解决方案架构师的小锦囊 - 架构图的 5 种类型
Jerry sometimes finds that the memory has been tampered with, but there is no exception. How should he find it? [chapter]
Arbitrary file reading vulnerability exploitation Guide
解决方案架构师的小锦囊 - 架构图的 5 种类型
Idea - indexing or scanning files to index every time you start
Example of pop-up task progress bar function based on pyqt5
707、设计链表(链表)