I am trying to obtain a graph using ggplot2. The problem is that I am not able to reduce the white-space between the legend border and the text. For example: ,
In this, I want to reduce the white space at the top that I have marked with some curly lines.
I searched a lot, but at most places, the answers suggest to reduce the key.height
or key.width
, but that is not what I want; I am pretty happy with those. I just want to get rid of the white space at the top.
You can remove the space for the legend title with:
theme(legend.title=element_blank())
If that's not sufficient then do:
theme(legend.title=element_blank(),
legend.margin=margin(c(1,5,5,5)))
and play around with the values (they're in the order top, right, bottom, left) until you get something you like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With