how to legend a multi graph with plot in r common legend for multiple plots in r

The solution for “how to legend a multi graph with plot in r common legend for multiple plots in r” can be found here. The following code will assist you in solving the problem.

plot_colors <- c("blue","black", "green", "orange", "pink")
  text <- c("Fabricated Metal", "Iron and Steel", "Paper", 
  "Beverages", "Tobacco")
  plot.new()
  par(xpd=TRUE)
  legend("center",legend = text, text.width = max(sapply(text, strwidth)),
         col=plot_colors, lwd=5, cex=1, horiz = TRUE)
  par(xpd=FALSE)# for ggplot
ggarrange(bxp, dp,  common.legend = TRUE)

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in