1

I'm relatively new to R and I can't for the life of me figure out how to make my barplot big enough so that it actually shows my legend below...

Here's what I have so far:

  r_plot <- read.table(text = "'Soziale Medien' 'Wissenschaftlicher Text'
                                50 48
                                44 37
                                5 11
                                1 2", header=TRUE)
  barplot(as.matrix(r_plot), beside=TRUE, col=rainbow(4))
  legend("bottom", legend=c("asd", "bc", "cd", "ef"), fill=rainbow(4), inset=c(0,-0.5), horiz=TRUE)

Which creates the following barplot (notice how the legend disappears below my bars!): Legend disappearing below plot...

I sincerely don't get how to fix this.

Community
  • 1
  • 1
Fabian Schneider
  • 345
  • 2
  • 10
  • Are you displaying the plot in RStudio? Try writing it to a device first (if you've shrunk your plot window within RStudio, the legend placement/sizing is a mess, but it may still show up fine if you write to, say, png or pdf). – MichaelChirico Mar 17 '17 at 21:49

0 Answers0