How do I adjust the spacing between individual labels in a legend in R?

I am trying to adjust the spacing between individual labels in the legend so that I can see all 9 labels, but unfortunately I have not been successful. Here is my code for creating frames

  # raw counts
  boxplot(log2(counts+1), col = col[as.integer(group)], las = 2,
        main = "Raw counts distribution", ylab = expression(log[2] ~ (raw ~ count + 1)))
  legend("top", levels(group), fill=col[1:nlevels(group)], horiz=TRUE)
  # norm counts
  boxplot(log2(norm.counts+1), col = col[as.integer(group)], las = 2,
        main = "Normalized counts distribution", ylab = expression(log[2] ~ (norm ~ count + 1)))
  legend("top", levels(group), fill=col[1:nlevels(group)], horiz=TRUE)

      

original boxplot

I even tried to include a function text.width

like this

    # raw counts
  boxplot(log2(counts+1), col = col[as.integer(group)], las = 2,
        main = "Raw counts distribution", ylab = expression(log[2] ~ (raw ~ count + 1)))
  legend("top", levels(group), fill=col[1:nlevels(group)], text.width = 0.2, horiz=TRUE)
  # norm counts
  boxplot(log2(norm.counts+1), col = col[as.integer(group)], las = 2,
        main = "Normalized counts distribution", ylab = expression(log[2] ~ (norm ~ count + 1)))
  legend("top", levels(group), fill=col[1:nlevels(group)], text.width = 0.2, horiz=TRUE)

      

but it got worse.

modified boxplot

How do I adjust the spaces to see all the labels?

+3
r legend boxplot


source to share


No one has answered this question yet

Check out similar questions:

765
How to remove a legend from a plot
674
How can we create xkcd style graphs?
548
Rotary and spacing labels on the ggplot2 axis
177
How to resize legend using matplotlib.pyplot
77
Is there a way to change the spacing between legend items in ggplot2?
eleven
Increase space between legend title and labels in ggplot2
eleven
Adjust the spacing between text in a horizontal legend
7
Matplotlib: how to adjust the space between legend markers and labels?
1
How do I adjust the space between 2 columns in the plot legend?
0
Struggle to add a legend to a square in R



All Articles
Loading...
X
Show
Funny
Dev
Pics