删除Y轴标题后图表发生变化

时间:2019-02-14 15:38:11

标签: r ggplot2

我遇到了ggplot2图表的奇怪行为。删除Y轴图表标题后,它也会更改。有人经历过类似的经历吗?似乎是因为添加轴名称后轴变窄而受到了影响,但是当colum1为0时仍然在我的数据最大值中,该值大于400,并且在减小图表后,您无法在列1的值0处看到此峰值。这是正常现象吗?这种类型的图表?

structure(list(place = c("y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", "y", 
"y", "y", "y", "y"), column1 = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 
42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 
58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 
74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 
90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 
105, 106, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 
119, 120, 122, 123, 124, 126, 127, 131, 132, 133, 134, 135, 136, 
137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 
151, 152, 153, 155, 156, 157, 158, 159, 160, 161, 164, 165, 166, 
168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 
181, 183, 184, 187, 190, 191, 192, 193, 194, 196, 197, 200, 201, 
202, 203, 204, 205, 206, 208, 209, 210, 212, 213, 214, 215, 217, 
218, 220, 222, 224, 225, 226, 228, 229, 231, 232, 233, 234, 235, 
236, 237, 238, 239, 241, 243, 247, 248, 249, 255, 256, 257, 259, 
261, 263, 267, 268, 269, 272, 273, 274, 275, 277, 278, 279, 280, 
281, 282, 283, 287, 288, 289, 291, 293, 294, 295, 297, 299, 302, 
304, 307, 308, 310, 313, 315, 316, 318, 319, 320, 321, 322, 323, 
324, 325, 326, 327, 329, 330, 333, 334, 338, 339, 341, 343, 344, 
347, 348, 349, 350, 352, 353, 354, 355, 360, 363, 364), column2 = c(418, 
12, 3, 3, 16, 6, 3, 6, 5, 3, 2, 2, 5, 7, 13, 9, 2, 5, 15, 18, 
59, 15, 11, 7, 19, 13, 10, 24, 23, 20, 57, 10, 8, 8, 22, 13, 
14, 3, 26, 13, 8, 7, 10, 6, 5, 14, 17, 12, 28, 15, 17, 9, 6, 
10, 9, 6, 17, 9, 7, 3, 10, 9, 4, 6, 3, 12, 5, 3, 6, 7, 4, 4, 
2, 10, 2, 3, 8, 5, 8, 36, 6, 11, 4, 10, 7, 7, 11, 7, 8, 8, 1, 
5, 3, 1, 2, 7, 2, 5, 3, 1, 1, 2, 5, 1, 4, 7, 2, 5, 4, 5, 8, 10, 
2, 1, 2, 2, 2, 5, 7, 1, 4, 4, 1, 12, 3, 4, 2, 1, 18, 2, 1, 2, 
3, 10, 1, 6, 2, 2, 6, 1, 5, 2, 3, 2, 1, 6, 3, 2, 1, 8, 1, 1, 
2, 1, 3, 4, 4, 3, 2, 1, 3, 4, 2, 3, 2, 2, 1, 4, 3, 3, 4, 1, 2, 
4, 2, 2, 2, 1, 3, 11, 4, 3, 3, 1, 1, 1, 2, 1, 2, 1, 6, 6, 2, 
1, 1, 2, 4, 1, 1, 2, 3, 14, 1, 2, 2, 4, 3, 1, 1, 1, 2, 1, 2, 
2, 1, 3, 6, 3, 1, 1, 4, 7, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 2, 
2, 4, 2, 1, 3, 3, 1, 1, 2, 1, 1, 1, 1, 2, 1, 4, 2, 1, 1, 2, 3, 
3, 2, 2, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 6, 3, 1, 3, 1, 2, 2, 
1, 4, 3, 1, 4, 1, 2, 2, 1)), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -285L), spec = structure(list(cols = list(
    place = structure(list(), class = c("collector_character", 
    "collector")), column1 = structure(list(), class = c("collector_double", 
    "collector")), column2 = structure(list(), class = c("collector_double", 
    "collector"))), default = structure(list(), class = c("collector_guess", 
"collector")), skip = 1), class = "col_spec"))

图表1:

    test_Copy %>% 
  filter(place == "y") %>%
  ggplot(aes(column1, column2)) +
  geom_area() +
  theme(axis.title = element_blank()) +
  facet_grid(~place)

图表2:

    test_Copy %>% 
  filter(place == "y") %>%
  ggplot(aes(column1, column2)) +
  geom_area() +
  facet_grid(~place)

增加的图表: enter image description here

图表减少: enter image description here

0 个答案:

没有答案