当前位置:网站首页>[data analysis and visualization] key points of data drawing 12- importance of chart notes
[data analysis and visualization] key points of data drawing 12- importance of chart notes
2022-06-13 02:35:00 【The winter holiday of falling marks】
Key points of data drawing 12- Importance of chart notes
Chart annotation is a key component of data visualization . It can turn boring graphics into an interesting and insightful way to convey information . At present, we pay less than five seconds' attention to reading on the Internet . therefore , If you can't get someone's attention in five seconds , Then you may have lost the audience . Adding accurate annotations can greatly help attract the attention of the audience . Use keywords 、 shape 、 Colors and other visual effects to help them get to the point . Annotation is a general concept , There are hundreds of different chart annotation methods , The specific use depends on the actual content , Let's look at a few examples .
List of articles
Example 1
The main danger in drawing a line chart is that you end up with a spaghetti chart : Too many groups can often lead to chart confusion , It is difficult to read any valid information , As shown in the figure below .
# Libraries
library(tidyverse)
library(hrbrthemes)
library(babynames)
library(viridis)
# Reading data
data <- babynames %>%
filter(name %in% c("Mary","Emma", "Ida", "Ashley", "Amanda", "Jessica", "Patricia", "Linda", "Deborah", "Dorothy", "Betty", "Helen")) %>%
filter(sex=="F")
# mapping
data %>%
ggplot( aes(x=year, y=n, group=name, color=name)) +
geom_line() +
scale_color_viridis(discrete = TRUE) +
theme(
legend.position="none",
plot.title = element_text(size=14)
) +
ggtitle("A spaghetti chart of baby names popularity")

You may want to highlight your main points , Instead of presenting this graphic to your audience . Then it is more meaningful to show only one variable data :
data %>%
mutate( highlight=ifelse(name=="Amanda", "Amanda", "Other")) %>%
# color Set specific data
ggplot( aes(x=year, y=n, group=name, color=highlight, size=highlight)) +
geom_line() +
scale_color_manual(values = c("#69b3a2", "lightgrey")) +
scale_size_manual(values=c(1.5,0.2)) +
theme(legend.position="none") +
ggtitle("Popularity of American names in the previous 30 years") +
geom_label( x=1990, y=55000, label="Amanda reached 3550\nbabies in 1970", size=4, color="#69b3a2") +
theme(
legend.position="none",
plot.title = element_text(size=14)
)

Example 2
When you show the audience several figures . The report consists of the following parts :1 individual barplot The figure shows the total amount of the company's five products ,1 A line chart shows the evolution of the benefits generated by these five products over the past decade :
# Read Library
library(tidyverse)
library(hrbrthemes)
library(patchwork)
library(viridis)
# Create data
data <- data.frame(
product = LETTERS[1:5],
value = c(10, 14, 18, 6, 15)
)
# mapping
a <- data %>%
ggplot( aes(x=product, y=value, fill=product)) +
geom_bar(stat="identity", width=0.5) +
scale_fill_viridis(discrete=TRUE) +
ggtitle("How much the products cost") +
theme(
plot.title = element_text(size=12),
legend.position = "none"
) +
xlab("") +
ylab("Cost in M$")
# Create data
data <- data.frame(
year = rep( seq(1,10), 5 ),
product = rep(LETTERS[1:5], each=10 ),
value = c(
seq(1,10) + sample( 1:3, 10, replace = TRUE),
seq(5,14) + sample( 4:10, 10, replace=TRUE),
seq(10,1)*2 + sample( 3:5, 10, replace=TRUE),
seq(20,11) + sample( 12:17, 10, replace=TRUE),
seq(1,10) + sample( 40:10, 10))
)
# mapping
b <- data %>%
ggplot( aes(x=year, y=value, color=product)) +
geom_line() +
scale_color_discrete() +
scale_x_continuous(breaks=c(1:10)) +
ggtitle("How much the products make") +
theme(
plot.title = element_text(size=12)
) +
xlab("Year") +
ylab("Benefit in M$")
# Show
a + b

You can see , It's hard to make a connection between two charts , Because each chart uses a different palette . product A Dark purple in the figure on the left , Red in the figure on the right . So when you have multiple shapes , Use the same color for the same item throughout the report .
data <- data.frame(
product = LETTERS[1:5],
value = c(10, 14, 18, 6, 15)
)
a <- data %>%
ggplot( aes(x=product, y=value, fill=product)) +
geom_bar(stat="identity", width=0.5) +
scale_fill_viridis(discrete=TRUE) +
ggtitle("How much the products cost") +
theme(
plot.title = element_text(size=12),
legend.position = "none"
) +
xlab("") +
ylab("Cost in M$")
data <- data.frame(
year = rep( seq(1,10), 5 ),
product = rep(LETTERS[1:5], each=10 ),
value = c(
seq(1,10) + sample( 1:3, 10, replace = TRUE),
seq(5,14) + sample( 4:10, 10, replace=TRUE),
seq(10,1)*2 + sample( 3:5, 10, replace=TRUE),
seq(20,11) + sample( 12:17, 10, replace=TRUE),
seq(1,10) + sample( 40:10, 10))
)
b <- data %>%
ggplot( aes(x=year, y=value, color=product)) +
geom_line() +
scale_color_viridis(discrete=TRUE) +
scale_x_continuous(breaks=c(1:10)) +
ggtitle("How much the products make") +
theme(
plot.title = element_text(size=12)
) +
xlab("Year") +
ylab("Benefit in M$")
# Show
a + b

Example 3
The ratio of the width to the height of a figure . It can have a significant impact on the insights gained from your graphics .
The following figure is an example of a line chart , It shows the data from 1749 Year to 1983 The annual number of sunspots in . This number is quite obvious in the solar cycle . The number of sunspots follows this pattern of solar activity 11 Annual periodic change , Make this line fluctuate up and down regularly . Obviously , Some peaks are higher than others , The maximum number of smooth sunspots is 50 To 180 Between .
library(tidyverse)
library(hrbrthemes)
# Reading data
data <- data.frame(
Year = as.numeric(time(sunspot.year)),
Sunspots = as.numeric(sunspot.year)
)
# mapping
data %>%
ggplot( aes(x=Year, y=Sunspots)) +
geom_line() +
ggtitle("Number of sunspots per year") +
theme(
plot.title = element_text(size=12)
)

Now let's change the aspect ratio of this graph , Make it wider and lower . To exaggerate the effect , Enlarge the drawing to 1800 Year to 1900 year . Here you can see the new results . The number of sunspots increases faster than it decreases . So try several different aspect ratios . This exploration greatly improves the value of graphics :
data %>%
filter(Year>1800 & Year<1900) %>%
ggplot( aes(x=Year, y=Sunspots)) +
geom_line() +
ggtitle("Number of sunspots per year") +
theme(
plot.title = element_text(size=12)
)

Reference resources
边栏推荐
- too old resource version,Code:410
- OneNote使用指南(一)
- Paper reading - beat tracking by dynamic programming
- Branch and bound method, example sorting
- Leetcode 926. Flip string to monotonically increasing [prefix and]
- Armv8-m learning notes - getting started
- Easydl related documents and codes
- Advanced stair climbing
- Linear, integer, nonlinear, dynamic programming
- ROS learning -5 how function packs with the same name work (workspace coverage)
猜你喜欢

ROS learning-8 pit for custom action programming

Priority queue with dynamically changing priority

Principle and steps of principal component analysis (PCA)

speech production model
![[reading papers] comparison of deeplobv1-v3 series, brief review](/img/80/714b8e5b2ad31b0a1a0b8320a3c714.jpg)
[reading papers] comparison of deeplobv1-v3 series, brief review

Paipai loan parent company Xinye quarterly report diagram: revenue of RMB 2.4 billion, net profit of RMB 530million, a year-on-year decrease of 10%

Think about the possibility of attacking secure memory through mmu/tlb/cache

Chapter7-11_ Deep Learning for Question Answering (2/2)
![[reading papers] dcgan, the combination of generating countermeasure network and deep convolution](/img/31/8c225627177169f1a3d6c48fd7e97e.jpg)
[reading papers] dcgan, the combination of generating countermeasure network and deep convolution

Area of basic exercise circle ※
随机推荐
Principle and steps of principal component analysis (PCA)
[reading papers] deepface: closing the gap to human level performance in face verification. Deep learning starts with the face
Gadgets: color based video and image cutting
[reading some papers] introducing deep learning into the public horizon alexnet
Sans certificate generation
How did you spend your winter vacation perfectly?
json,xml,txt
Basic exercises of test questions letter graphics ※
SANs证书生成
About the fact that I gave up the course of "Guyue private room course ROS manipulator development from introduction to actual combat" halfway
[keras] train py
02 optimize the default structure of wechat developer tools
Understand HMM
02 优化微信开发者工具默认的结构
Common web page status return code crawler
Is space time attention all you need for video understanding?
[reading point paper] yolo9000:better, faster, stronger, (yolov2), integrating various methods to improve the idea of map and wordtree data fusion
Thinking back from the eight queens' question
redis 多个服务器共用一个
[pytorch]fixmatch code explanation (super detailed)