面积图显示较大的值低于较小的值

Posted

技术标签:

【中文标题】面积图显示较大的值低于较小的值【英文标题】:Area chart displays bigger values lower than smaller values 【发布时间】:2021-11-09 16:04:00 【问题描述】:

我想显示一个包含实际值和累积值的面积图。虽然我希望实际值的显示低于累积值,但相反的情况会发生,并且还会以非常奇怪的方式显示图表。

Tar<-structure(list(Week = structure(c(1L, 1L, 15L, 15L, 20L, 20L, 
8L, 8L, 3L, 3L, 18L, 18L, 16L, 16L, 14L, 14L, 5L, 5L, 14L, 14L, 
15L, 15L, 8L, 8L, 10L, 10L, 19L, 19L, 5L, 5L, 17L, 17L, 20L, 
20L, 18L, 18L, 18L, 18L, 2L, 2L, 3L, 3L, 8L, 8L, 20L, 20L, 20L, 
20L, 7L, 7L, 5L, 5L, 2L, 2L, 18L, 18L, 16L, 16L, 7L, 7L, 20L, 
20L, 17L, 17L, 20L, 20L, 20L, 20L, 5L, 5L, 15L, 15L, 16L, 16L, 
6L, 6L, 14L, 14L, 20L, 20L, 15L, 15L, 8L, 8L, 18L, 18L, 14L, 
14L, 16L, 16L, 18L, 18L, 5L, 5L, 5L, 5L, 20L, 20L, 20L, 20L, 
20L, 20L, 1L, 1L, 16L, 16L, 7L, 7L, 9L, 9L, 15L, 15L, 18L, 18L, 
20L, 20L, 15L, 15L, 3L, 3L, 19L, 19L, 14L, 14L, 17L, 17L, 10L, 
10L, 20L, 20L, 9L, 9L, 18L, 18L, 18L, 18L, 14L, 14L, 5L, 5L, 
18L, 18L, 14L, 14L, 9L, 9L, 17L, 17L, 16L, 16L, 9L, 9L, 10L, 
10L, 14L, 14L, 15L, 15L, 7L, 7L, 20L, 20L, 20L, 20L, 10L, 10L, 
18L, 18L, 10L, 10L, 20L, 20L, 11L, 11L, 8L, 8L, 17L, 17L, 15L, 
15L, 20L, 20L, 15L, 15L, 11L, 11L, 8L, 8L, 5L, 5L, 16L, 16L, 
7L, 7L, 14L, 14L, 15L, 15L, 14L, 14L, 17L, 17L, 14L, 14L, 20L, 
20L, 14L, 14L, 15L, 15L, 14L, 14L, 5L, 5L, 19L, 19L, 18L, 18L, 
14L, 14L, 3L, 3L, 14L, 14L, 8L, 8L, 14L, 14L, 15L, 15L, 3L, 3L, 
20L, 20L, 5L, 5L, 20L, 20L, 17L, 17L, 19L, 19L, 8L, 8L, 8L, 8L, 
9L, 9L, 14L, 14L, 3L, 3L, 20L, 20L, 19L, 19L, 17L, 17L, 3L, 3L, 
14L, 14L, 1L, 1L, 16L, 16L, 18L, 18L, 18L, 18L, 20L, 20L, 18L, 
18L, 16L, 16L, 16L, 16L, 7L, 7L, 15L, 15L, 20L, 20L, 17L, 17L, 
8L, 8L, 16L, 16L, 15L, 15L, 3L, 3L, 19L, 19L, 15L, 15L, 17L, 
17L, 2L, 2L, 20L, 20L, 10L, 10L, 16L, 16L, 14L, 14L, 8L, 8L, 
18L, 18L, 6L, 6L, 10L, 10L, 17L, 17L, 3L, 3L, 17L, 17L, 18L, 
18L, 18L, 18L, 14L, 14L, 15L, 15L, 14L, 14L, 14L, 14L, 18L, 18L, 
16L, 16L, 14L, 14L, 4L, 4L, 18L, 18L, 13L, 13L, 6L, 6L, 14L, 
14L, 15L, 15L, 14L, 14L, 3L, 3L, 16L, 16L, 18L, 18L, 4L, 4L, 
2L, 2L, 8L, 8L, 3L, 3L, 14L, 14L, 5L, 5L, 18L, 18L, 8L, 8L, 19L, 
19L, 17L, 17L, 14L, 14L, 17L, 17L, 20L, 20L, 17L, 17L, 15L, 15L, 
18L, 18L, 10L, 10L, 2L, 2L, 15L, 15L, 8L, 8L, 14L, 14L, 16L, 
16L, 14L, 14L, 5L, 5L, 19L, 19L, 5L, 5L, 4L, 4L, 17L, 17L, 6L, 
6L, 6L, 6L, 4L, 4L, 13L, 13L, 18L, 18L, 2L, 2L, 17L, 17L, 14L, 
14L, 20L, 20L, 6L, 6L, 3L, 3L, 15L, 15L, 18L, 18L, 6L, 6L, 3L, 
3L, 20L, 20L, 11L, 11L, 20L, 20L, 16L, 16L, 8L, 8L, 18L, 18L, 
7L, 7L, 14L, 14L, 1L, 1L, 4L, 4L, 20L, 20L, 20L, 20L, 8L, 8L, 
18L, 18L, 1L, 1L, 14L, 14L, 4L, 4L, 14L, 14L, 18L, 18L, 4L, 4L, 
5L, 5L, 6L, 6L, 20L, 20L, 2L, 2L, 8L, 8L, 18L, 18L, 18L, 18L, 
15L, 15L, 7L, 7L, 17L, 17L, 20L, 20L, 8L, 8L, 5L, 5L, 16L, 16L, 
13L, 13L, 12L, 12L, 16L, 16L, 17L, 17L, 20L, 20L, 9L, 9L, 4L, 
4L, 14L, 14L, 15L, 15L, 20L, 20L, 5L, 5L, 18L, 18L, 4L, 4L, 16L, 
16L, 2L, 2L, 6L, 6L, 7L, 7L, 3L, 3L, 13L, 13L, 13L, 13L, 20L, 
20L, 18L, 18L, 17L, 17L, 14L, 14L, 18L, 18L, 12L, 12L, 7L, 7L, 
20L, 20L, 4L, 4L, 13L, 13L, 6L, 6L, 5L, 5L, 6L, 6L, 20L, 20L, 
20L, 20L, 14L, 14L, 6L, 6L, 5L, 5L, 4L, 4L, 2L, 2L, 17L, 17L, 
9L, 9L, 15L, 15L, 16L, 16L, 18L, 18L, 16L, 16L, 4L, 4L, 6L, 6L, 
13L, 13L, 17L, 17L, 8L, 8L, 17L, 17L, 7L, 7L, 5L, 5L, 15L, 15L, 
1L, 1L, 6L, 6L, 4L, 4L, 20L, 20L, 5L, 5L, 3L, 3L, 6L, 6L, 20L, 
20L, 13L, 13L, 8L, 8L, 18L, 18L, 4L, 4L, 7L, 7L, 5L, 5L, 6L, 
6L, 16L, 16L, 18L, 18L, 20L, 20L, 20L, 20L, 20L, 20L, 6L, 6L, 
13L, 13L, 5L, 5L, 16L, 16L, 17L, 17L, 6L, 6L, 13L, 13L, 8L, 8L, 
15L, 15L, 6L, 6L, 4L, 4L, 8L, 8L, 13L, 13L, 3L, 3L, 6L, 6L, 20L, 
20L, 18L, 18L, 6L, 6L, 13L, 13L, 14L, 14L, 11L, 11L, 8L, 8L, 
7L, 7L, 4L, 4L, 16L, 16L, 16L, 16L, 17L, 17L, 1L, 1L, 5L, 5L, 
17L, 17L, 5L, 5L, 20L, 20L, 20L, 20L, 4L, 4L, 6L, 6L, 15L, 15L, 
7L, 7L, 18L, 18L, 17L, 17L, 17L, 17L, 3L, 3L, 5L, 5L, 18L, 18L, 
16L, 16L, 18L, 18L, 18L, 18L, 20L, 20L, 6L, 6L, 16L, 16L, 2L, 
2L, 8L, 8L, 20L, 20L, 16L, 16L, 6L, 6L, 8L, 8L, 3L, 3L, 15L, 
15L, 16L, 16L, 19L, 19L, 16L, 16L, 18L, 18L, 5L, 5L, 17L, 17L, 
4L, 4L, 6L, 6L, 16L, 16L, 6L, 6L, 20L, 20L, 17L, 17L, 7L, 7L, 
7L, 7L, 2L, 2L, 18L, 18L, 18L, 18L, 20L, 20L, 7L, 7L, 16L, 16L, 
2L, 2L, 15L, 15L, 20L, 20L, 15L, 15L, 4L, 4L, 5L, 5L, 16L, 16L, 
6L, 6L, 19L, 19L, 3L, 3L, 18L, 18L, 6L, 6L, 7L, 7L, 18L, 18L, 
20L, 20L, 17L, 17L, 18L, 18L, 6L, 6L, 9L, 9L), .Label = c("1", 
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", 
"14", "15", "16", "17", "18", "19", "20"), class = "factor"), 
    Type = c("Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target", "Cumilative target", 
    "Actual target", "Cumilative target", "Actual target"), Count = c(5, 
    7, 323, 29, 448, 52, 148, 25, 28, 19, 398, 47, 348, 33, 298, 
    37, 73, 27, 298, 37, 323, 29, 148, 25, 198, 8, 423, 10, 73, 
    27, 373, 31, 448, 52, 398, 47, 398, 47, 13, 12, 28, 19, 148, 
    25, 448, 52, 448, 52, 123, 18, 73, 27, 13, 12, 398, 47, 348, 
    33, 123, 18, 448, 52, 373, 31, 448, 52, 448, 52, 73, 27, 
    323, 29, 348, 33, 98, 29, 298, 37, 448, 52, 323, 29, 148, 
    25, 398, 47, 298, 37, 348, 33, 398, 47, 73, 27, 73, 27, 448, 
    52, 448, 52, 448, 52, 5, 7, 348, 33, 123, 18, 173, 8, 323, 
    29, 398, 47, 448, 52, 323, 29, 28, 19, 423, 10, 298, 37, 
    373, 31, 198, 8, 448, 52, 173, 8, 398, 47, 398, 47, 298, 
    37, 73, 27, 398, 47, 298, 37, 173, 8, 373, 31, 348, 33, 173, 
    8, 198, 8, 298, 37, 323, 29, 123, 18, 448, 52, 448, 52, 198, 
    8, 398, 47, 198, 8, 448, 52, 223, 4, 148, 25, 373, 31, 323, 
    29, 448, 52, 323, 29, 223, 4, 148, 25, 73, 27, 348, 33, 123, 
    18, 298, 37, 323, 29, 298, 37, 373, 31, 298, 37, 448, 52, 
    298, 37, 323, 29, 298, 37, 73, 27, 423, 10, 398, 47, 298, 
    37, 28, 19, 298, 37, 148, 25, 298, 37, 323, 29, 28, 19, 448, 
    52, 73, 27, 448, 52, 373, 31, 423, 10, 148, 25, 148, 25, 
    173, 8, 298, 37, 28, 19, 448, 52, 423, 10, 373, 31, 28, 19, 
    298, 37, 5, 7, 348, 33, 398, 47, 398, 47, 448, 52, 398, 47, 
    348, 33, 348, 33, 123, 18, 323, 29, 448, 52, 373, 31, 148, 
    25, 348, 33, 323, 29, 28, 19, 423, 10, 323, 29, 373, 31, 
    13, 12, 448, 52, 198, 8, 348, 33, 298, 37, 148, 25, 398, 
    47, 98, 29, 198, 8, 373, 31, 28, 19, 373, 31, 398, 47, 398, 
    47, 298, 37, 323, 29, 298, 37, 298, 37, 398, 47, 348, 33, 
    298, 37, 48, 19, 398, 47, 273, 12, 98, 29, 298, 37, 323, 
    29, 298, 37, 28, 19, 348, 33, 398, 47, 48, 19, 13, 12, 148, 
    25, 28, 19, 298, 37, 73, 27, 398, 47, 148, 25, 423, 10, 373, 
    31, 298, 37, 373, 31, 448, 52, 373, 31, 323, 29, 398, 47, 
    198, 8, 13, 12, 323, 29, 148, 25, 298, 37, 348, 33, 298, 
    37, 73, 27, 423, 10, 73, 27, 48, 19, 373, 31, 98, 29, 98, 
    29, 48, 19, 273, 12, 398, 47, 13, 12, 373, 31, 298, 37, 448, 
    52, 98, 29, 28, 19, 323, 29, 398, 47, 98, 29, 28, 19, 448, 
    52, 223, 4, 448, 52, 348, 33, 148, 25, 398, 47, 123, 18, 
    298, 37, 5, 7, 48, 19, 448, 52, 448, 52, 148, 25, 398, 47, 
    5, 7, 298, 37, 48, 19, 298, 37, 398, 47, 48, 19, 73, 27, 
    98, 29, 448, 52, 13, 12, 148, 25, 398, 47, 398, 47, 323, 
    29, 123, 18, 373, 31, 448, 52, 148, 25, 73, 27, 348, 33, 
    273, 12, 248, 2, 348, 33, 373, 31, 448, 52, 173, 8, 48, 19, 
    298, 37, 323, 29, 448, 52, 73, 27, 398, 47, 48, 19, 348, 
    33, 13, 12, 98, 29, 123, 18, 28, 19, 273, 12, 273, 12, 448, 
    52, 398, 47, 373, 31, 298, 37, 398, 47, 248, 2, 123, 18, 
    448, 52, 48, 19, 273, 12, 98, 29, 73, 27, 98, 29, 448, 52, 
    448, 52, 298, 37, 98, 29, 73, 27, 48, 19, 13, 12, 373, 31, 
    173, 8, 323, 29, 348, 33, 398, 47, 348, 33, 48, 19, 98, 29, 
    273, 12, 373, 31, 148, 25, 373, 31, 123, 18, 73, 27, 323, 
    29, 5, 7, 98, 29, 48, 19, 448, 52, 73, 27, 28, 19, 98, 29, 
    448, 52, 273, 12, 148, 25, 398, 47, 48, 19, 123, 18, 73, 
    27, 98, 29, 348, 33, 398, 47, 448, 52, 448, 52, 448, 52, 
    98, 29, 273, 12, 73, 27, 348, 33, 373, 31, 98, 29, 273, 12, 
    148, 25, 323, 29, 98, 29, 48, 19, 148, 25, 273, 12, 28, 19, 
    98, 29, 448, 52, 398, 47, 98, 29, 273, 12, 298, 37, 223, 
    4, 148, 25, 123, 18, 48, 19, 348, 33, 348, 33, 373, 31, 5, 
    7, 73, 27, 373, 31, 73, 27, 448, 52, 448, 52, 48, 19, 98, 
    29, 323, 29, 123, 18, 398, 47, 373, 31, 373, 31, 28, 19, 
    73, 27, 398, 47, 348, 33, 398, 47, 398, 47, 448, 52, 98, 
    29, 348, 33, 13, 12, 148, 25, 448, 52, 348, 33, 98, 29, 148, 
    25, 28, 19, 323, 29, 348, 33, 423, 10, 348, 33, 398, 47, 
    73, 27, 373, 31, 48, 19, 98, 29, 348, 33, 98, 29, 448, 52, 
    373, 31, 123, 18, 123, 18, 13, 12, 398, 47, 398, 47, 448, 
    52, 123, 18, 348, 33, 13, 12, 323, 29, 448, 52, 323, 29, 
    48, 19, 73, 27, 348, 33, 98, 29, 423, 10, 28, 19, 398, 47, 
    98, 29, 123, 18, 398, 47, 448, 52, 373, 31, 398, 47, 98, 
    29, 173, 8)), row.names = c(NA, -858L), class = "data.frame")
    
library(ggplot2)
library(dplyr)
library(plotly)
p <-
    ggplot(Tar, aes(x = Week, y = Count, fill = Type))+
    geom_area(alpha = 0.6 , size = 0.5, colour = "white", stat = "identity", orientation = "x") +
    labs(fill = NULL)+
    theme(legend.position = "bottom")
p <- p+labs(title = "Figure 1: Weekly Cumulative Projected Enrollment vs Weekly Cumulative Actual Enrollment",
            subtitle = "Cum Weekly Projected Enrollment/Cum Weekly Actual Enrollment")


# not printed
ggplotly(p)

它应该是这样的:

【问题讨论】:

【参考方案1】:

您的数据中每个组和每周都有重复的条目,因此看起来很混乱。此外,为了不堆叠当前和累积,这是相当误导的,您可以设置position = "identity"。我通过因子转换将实际值放在了前面,但你可以随意处理。

library(ggplot2)
library(dplyr)
library(plotly)
clean_data <- Tar %>% 
  distinct() %>% 
  mutate(Type = ordered(Type, levels = unique(Type)[2:1]))

p <- ggplot(clean_data, aes(x = Week, y = Count, fill = Type, group = Type)) +
  geom_area(alpha = 0.6 , size = 0.5, colour = "white", position = "identity", orientation = "x") +
  labs(fill = NULL)+
  theme(legend.position = "bottom")
p <- p+labs(title = "Figure 1: Weekly Cumulative Projected Enrollment vs Weekly Cumulative Actual Enrollment",
            subtitle = "Cum Weekly Projected Enrollment/Cum Weekly Actual Enrollment")

p
# not printed
ggplotly(p)

【讨论】:

我已经编辑了我的整个数据集,但我不明白为什么我现在得到一个空图 实际上我不确定是什么导致了这个错误,但专门设置group = Type 解决了这个问题。见上文【参考方案2】:

mnist's answer 完成并解决了问题。他提到您的数据集上有重复的记录。您可以删除它们或计算平均值或总数(现在不确定是否应该存在重复项)。 这是对Type 重新排序并通过将legend.title = element_blank() 添加到theme 部分来删除多余行(labs(fill = NULL)+)的替代方法。在这种特定情况下,您还可以删除 stat = identity

编辑:

由于原始帖子已使用整个数据集进行了更新,因此我正在更新我的答案。 现在您必须使用group 才能使其工作:

library(tidyverse)
library(plotly)
p <- Tar %>% 
  group_by(Week, Type) %>% 
  summarise(mean_count = mean(Count)) %>% 
  mutate(Type = factor(Type, levels = rev(unique(Type)))) %>% 
  ggplot(aes(x = Week, y = mean_count,
             group = Type)) +
  geom_area(aes(fill = Type),
            alpha = 0.6 , 
            size = 0.5, 
            stat = "identity",
            colour = "white", 
            orientation = "x") +
  theme(legend.position = "bottom",
        legend.title = element_blank())

p <- p +
  labs(title = "Figure 1: Weekly Cumulative Projected Enrollment vs Weekly Cumulative Actual Enrollment",
       subtitle = "Cum Weekly Projected Enrollment/Cum Weekly Actual Enrollment")

旧答案:


library(tidyverse)
library(plotly)

p <- Tar %>%
  group_by(Week, Type) %>% 
  summarise(mean_count = mean(Count)) %>% 
  mutate(Type = factor(Type, levels = rev(unique(Type)))) %>% 
  ggplot(aes(x = Week, 
             y = mean_count, 
             fill = Type)) +
  geom_area(alpha = 0.6 , 
            size = 0.5, 
            colour = "white", 
            orientation = "x") +
  theme(legend.position = "bottom",
        legend.title = element_blank())

p <- p +
  labs(title = "Figure 1: Weekly Cumulative Projected Enrollment vs Weekly Cumulative Actual Enrollment",
       subtitle = "Cum Weekly Projected Enrollment/Cum Weekly Actual Enrollment")

p

请注意,您的数据有错字:您写的是 Cumative 而不是 Cumulative

【讨论】:

我已经编辑了我的整个数据集,但我不明白为什么我现在得到一个空图 嗨@firmo23 我已经编辑了我的答案。请注意,您必须使用group 才能使其工作。另请注意,我使用的是mean,但根据图表的用途,您可以改用sum

以上是关于面积图显示较大的值低于较小的值的主要内容,如果未能解决你的问题,请参考以下文章

利用Python创作热力图

调用`strcat`并能够将较大的字符串存储到较小的字符串中?

中位数

QGIS制图中面积小的区域不显示注记

QGIS制图中面积小的区域不显示注记

使用滑块更改 Phong 着色器的值