0

I've been trying quite some features but I can't fix my legend. The text in my legend keeps overlapping. Increasing or decreasing CEX does not work, which seems to be the feature to adjust your text / box size. Thank you in advance

The code and image are below.enter image description here

barplot(as.matrix(mydata), main='Sentiment all companies over the years 2013-2016', ylab = 'total',
        xlab = "", beside = TRUE, col=brewer.pal(10, 'RdYlGn'))
legend(13,800,c("negative", 'anger', 'disgust', 'fear', 'sadness', 'surprise',
                             'anticipation','trust', 'joy', 'positive'), cex = 2.2,
                              fill = brewer.pal(10,'RdYlGn'), bty = 'n')
Wally530
  • 23
  • 2
  • In the `legend` call, you should be able to add `between = 5` to add spacing, and then adjust the number as needed, if you need more or less space. – Matt Jun 03 '20 at 18:58
  • 1
    I might be wrong, but after running the `barplot` code you're probably scaling the RStudio preview window with the mouse, don't you? You may scale and then run the code again, so the legend rejects itself. However, it's much better to work with another device such as `png`. See: https://stackoverflow.com/questions/7144118/how-to-save-a-plot-as-image-on-the-disk – jay.sf Jun 03 '20 at 18:59
  • 1
    Thank you for your quick answers (@Matt) ! @jay.sf you are totally right. Once I export the the plot and adjust the resolution, it's all fine – Wally530 Jun 03 '20 at 19:04

0 Answers0