I’m working to build a Shiny app. I want to move my legend generated by ma aes(fill) in my plot for aesthetic reasons. So here’s a piece of the code :
output$graphique_5 <- plotly::renderPlotly({
graphique_5 <- ggplot(data = Data_GPS_G5_filtre())+
(aes(x = Date, y = Acc_Load, fill = day))+
geom_col(aes(fill = day), alpha = 0.5)+
scale_fill_manual(values = c("#990000", "forestgreen", "#339999", "#CC3366", "#CC6600","#000066","#660066"))+
geom_text(aes(label = Acc_Load), color = "black", vjust = 1.2)+
theme(panel.background = element_rect("white"),
panel.border = element_rect(fill = NA, color = "black"),
plot.title = element_text(size = 18, color = "darkgrey", family = "Impact", hjust = 0.5),
axis.title = element_text(size = 11, color = "darkgrey", family = "Impact"),
axis.text = element_text(size = 11, color = "darkgrey", family = "Impact"),
text = element_text(family = "Impact", color = "black"),
legend.position = "top"
)+
guides(fill = guide_legend(position = "top")) + # Ajoutez cette ligne pour forcer la position de la légende
labs(title = "Rapport des Acceleration Loads par jour",
y = "Valeurs Acceleration Loads")
return(graphique_5)
By default the legend is right side positioned and I want to move below or above my visualization.
As you can see, I already try to use legend.position and guides(fill = guide_legend()) but it doesn’t change anything. May someone help me, please? Thanks.