答案 0 :(得分:5)
您可以执行以下操作:
library(ggplot2)
ggplot(df, aes(x = x, y = 1, label= label))+
scale_x_continuous(limits = c(0,100))+
geom_segment(x = 0, xend = 100, y = 1, yend = 1, color = "blue")+
geom_segment(x = 0, xend = 0, y = 0.99, yend = 1.01, color = "blue")+
geom_segment(x = 100, xend = 100, y = 0.99, yend = 1.01, color = "blue")+
geom_point(color = "red", size = 3)+
geom_segment(aes(x = x, xend = x, y = 0.99, yend = 1.01),color = "red")+
ylim(0.9,1.1)+
geom_text(aes(y = 1.025))+
geom_text(aes(y = 0.975, label = paste(x,"%", sep = "")))+
annotate(geom= "text",label = 0, y = 0.975, x = 0)+
annotate(geom = "text", label = 100, y = 0.975, x = 100)+
theme_void()
可复制的数据
df <- data.frame(x = c(10,25,65),
label = c("Variable1","Variable2","Variable3"))