0

I have three groups (Tissue) and two groups (Treatment) represented in a faceted boxplot and I would like to remove the legend for "treatment", as it is already represented in the graph and keep the legend for "Tissue".

box <- ggboxplot(subclusDF, x = 'Treatment', y = 'ATP4', fill = "Tissue", color = 'Tissue', palette = qualitative_hcl(3, palette = 'Dark 3'), add = 'jitter', shape = 'Treatment'  )
box <- box + labs(title= 'GHRL') + xlab(NULL) + ylab("Expression") + facet_grid(~Tissue)
box

box + theme()+
theme(
  plot.title = element_text(face = "bold", size = 12),
  legend.background = element_rect(fill = "white", size = 4, colour = "white"),
  legend.justification = c(0, 1),
  legend.title=element_text(NULL),
  legend.key = element_blank(),
  legend.position = c(0, 1),
  axis.text = (NULL),
  axis.ticks = element_line(colour = "grey70", size = 0.2),
  panel.grid.major = element_line(colour = "grey70", size = 0.2),
  panel.grid.minor = element_blank()
)
 box
Marion
  • 1
  • 1
  • It would be good to include your code so we can give you specific feedback. Edit: check the [cookbook](http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/#removing-the-legend). – o_v Dec 22 '21 at 13:21
  • Thanks for that, I want to specially remove one legend and not the other, so not sure the cookbook handles that, but will look again – Marion Dec 22 '21 at 14:53
  • You can try `+ scale_shape_discrete(guide = "none")`, but this is an untested guess because I cannot reproduce the issue. Or `+ guides(shape = "none")`. – teunbrand Dec 22 '21 at 15:53
  • 1
    Does this answer your question? [Remove legend ggplot 2.2](https://stackoverflow.com/questions/35618260/remove-legend-ggplot-2-2) – tjebo Dec 22 '21 at 17:19

1 Answers1

0

So, specifically you'd want to remove the legend for shape:


box + 
guides(shape = F)

o_v
  • 102
  • 8