Я пытаюсь построить несколько графиков, помеченных «A», «B», «C» в верхнем левом углу. Я не могу понять (или найти) решение, чтобы добавить это текстовое поле, например метку. В идеале это увеличило бы весь размер влево. Любая помощь приветствуется!
«А» - это то, что я хотел бы добавить, часть сюжета - это то, что у меня уже есть.
введите описание изображения здесь
Вот пример набора данных и мой текущий код:
Day=rep(1:6, times=15)
Colour=c("Yellow", "Yellow","Yellow","Yellow","Yellow","Yellow",
"Red", "Red","Red","Red","Red","Red",
"Green","Green","Green","Green","Green","Green",
"Yellow", "Yellow","Yellow","Yellow","Yellow","Yellow",
"Red", "Red","Red","Red","Red","Red",
"Green","Green","Green","Green","Green","Green",
"Blue","Blue","Blue","Blue","Blue","Blue",
"Purple","Purple","Purple","Purple","Purple","Purple",
"Yellow", "Yellow","Yellow","Yellow","Yellow","Yellow",
"Red", "Red","Red","Red","Red","Red",
"Green","Green","Green","Green","Green","Green",
"Yellow", "Yellow","Yellow","Yellow","Yellow","Yellow",
"Red", "Red","Red","Red","Red","Red",
"Green","Green","Green","Green","Green","Green",
"Yellow", "Yellow","Yellow","Yellow","Yellow","Yellow")
Values=rep(c(9,8,7,6,5,8,7,6,5,4,7,6,5,4,3), times=6)
Fruit=rep(c("Apple", "Banana", "Blueberry","Mango", "Melon", "Pear"),
times = c(18,18,12,18,18,6))
Data <-data.frame(Day, Fruit, Colour, Values) %>%
mutate(unten=Values-0.2, oben=Values+0.2) %>% filter(Day==1)
design <- theme( strip.background = element_blank(),
panel.background = element_blank(), panel.border=element_blank(),
panel.grid.major = element_blank(), strip.placement = "outside",
axis.line.x = element_line(colour = "white"),
axis.ticks.x=element_blank(), legend.position = "none",
axis.text.x=element_text(vjust=5), axis.title=element_text(size=15),
axis.title.y = element_text(
margin = margin(t = 0, r = 15, b = 0, l = 0)), strip.text = element_text(size = 15), axis.text=element_text(size=11),
plot.title = element_text(size = 18, face = "bold"))
ForPlot <- ggplot(Data, aes(Colour, Values), fill=Colour)
ylines <- c(0, 5, 10)
ForPlot + theme_classic() +
geom_hline(yintercept = ylines, colour= "lightgrey" )+
scale_y_continuous(breaks=ylines,
limits=c(0,10),
labels=ylines
)+
geom_col(position=position_dodge2 (preserve = "single"),
aes(fill=`Colour`),width=.7)+
ylab("Values") + xlab("Colour") +
ggtitle("Title")+
facet_grid(~`Fruit`, scales = "free_x", space = "free_x", switch = "y") +
design +
scale_fill_manual("Colour", values=c('Blue', 'Green', 'Purple','Red', 'Yellow'))+
geom_text(aes(label = Values, y = Values), size=3, vjust = -.3) +
geom_segment(aes(x=0.4,xend=Inf, y=0, yend=0), color="black")