Having three plots like this:
df <- data.frame(stock = c("google", "google", "amazon", "amazon", "amazon", "yahoo", "yahoo", "yahoo"), status = c("open", "close", "open", "buy", "close", "open", "buy", "close"), category = c("daily", "daily", "daily", "daily", "daily", "daily", "daily", "daily"), price = c(330379.36, 52324.62, 545240.22, 192574.83, 46721.34, 477658.62, 146724.44, 42721.78))
plot1:
plot1 <- ggplot(df,8 aes(fill=stock, y=reorder(price, status), x= status)) +
geom_bar(position="dodge", stat="identity") +
ggtitle("Daily") +
theme(axis.text.x = element_text(angle = 45, vjust = 0, hjust=0)) +
geom_text(aes(label=price), position = position_dodge(width= 1), vjust=0.5) +
scale_fill_manual(values = c("#492ecb", "#5041ae", "#ff53aa"))
plot2:
plot2 <- ggplot(df,8 aes(fill=stock, y=reorder(price, status), x= status)) +
geom_bar(position="dodge", stat="identity") +
ggtitle("Daily") +
theme(axis.text.x = element_text(angle = 45, vjust = 0, hjust=0)) +
geom_text(aes(label=price), position = position_dodge(width= 1), vjust=0.5) +
scale_fill_manual(values = c("#492ecb", "#5041ae", "#ff53aa"))
plot3:
plot3 <- ggplot(df,8 aes(fill=stock, y=reorder(price, status), x= status)) +
geom_bar(position="dodge", stat="identity") +
ggtitle("Daily") +
theme(axis.text.x = element_text(angle = 45, vjust = 0, hjust=0)) +
geom_text(aes(label=price), position = position_dodge(width= 1), vjust=0.5) +
scale_fill_manual(values = c("#492ecb", "#5041ae", "#ff53aa"))
and adding them into one plot:
plot_grid(plot1, plot2, plot3, ncol=3, nrow=1)
How can it be possible to have the legend appear only once? The legend is based on the fill aesthetic
