【发布时间】:2020-03-15 15:21:52
【问题描述】:
我有以下代码和后续图表。我该怎么做:
1) 使我的 PY 轴包含所有 PY(即包括 2009、2011、2013、2015 和 2017)
2) 按升序排列(即 2009 年在顶部,2018 年在底部
3) 更改我的 Perc 轴的比例,可能是 0.2 而不是 0.25,并且可能添加更多网格线
数据:
structure(list(PY = structure(c(1230768000, 1262304000, 1293840000,
1325376000, 1356998400, 1388534400, 1420070400, 1451606400, 1483228800,
1514764800, 1546300800), class = c("POSIXct", "POSIXt"), tzone = "UTC"),
Perc = c(0.197, 0.266, 0.2, 0.3, 0.397, 0.553, 0.57, 0.621,
0.556, 0.6, 0.293)), row.names = c(NA, -11L), class = c("tbl_df",
"tbl", "data.frame"))
代码:
ggplot(Ult_sum, aes(x=PY, y=Perc)) +
geom_segment( aes(x=PY, xend=PY, y=0, yend=1.0), color="skyblue") +
geom_point( color="blue", size=4, alpha=0.6) +
# theme_light() +
coord_flip() +
theme(
panel.grid.major.y = element_blank(),
panel.border = element_blank(),
axis.ticks.y = element_blank()
)
图表:
作为奖励,我还收到以下警告/错误:
Warning messages:
1: Removed 1 rows containing missing values (geom_segment).
2: Removed 1 rows containing missing values (geom_point).
这似乎无缘无故地删除了我的 PY 2019。想法?
【问题讨论】:
-
请编辑您的问题以包含重现您的问题所需的数据 - 使用
dput(Ult_sum)将数据转换为易于导入的格式 -
添加了我的数据视图。让我知道这是否足够。
-
我想我做到了! (对不起,我是新手)