【发布时间】:2017-07-14 21:45:18
【问题描述】:
我确定这很简单,但我想不通。
我有以下图表:
library(data.table)
library(magrittr)
library(ggplot2)
cambodia <-
data.table(Period = c("Funan", "Chenla/Zhenla","Khmer Empire","Dark Ages of Cambodia"),
StartDate = c(-500,550,802,1431),
EndDate = c(550,802,1431,1863),
Color = c("lightblue","lightgreen","lightyellow","pink")) %>%
extract(order(-StartDate)) %>%
extract(, Period := factor(Period,levels = Period))
ggplot() +
geom_segment(data=cambodia, aes(x=StartDate, xend=EndDate, y=Period, yend=Period, color=Color),
linetype=1, size=2) +
scale_colour_brewer(palette = "Pastel1")+
xlab("Date")+
ylab("Ruler")+
theme_bw() +
theme(panel.grid.minor = element_blank(), panel.grid.major = element_blank()) +
theme(aspect.ratio = .2) +
theme(legend.position="none")
但我希望标签不在轴上并在页面上。在线的左边或中间的顶部。例如
geom_text 的大多数示例都给了我 gobbledeegook。我似乎无法将它们应用于我在这里拥有的因子数据。你知道怎么做吗? 谢谢
【问题讨论】: