1

Is it possible to remove particular entries just from the legend, while keeping them on the actual plot?

In particular, I have a dodged geom_bar where I wanted to change the colours of the last entry as they show a mean over the previous bars. To do this, I've created a new groups, called _A and _B.

However, in the legend I want to show just the entries for A and B, omitting the special groups I've created. Any ideas on how to do this?

enter image description here

If I set their labels to an empty string, the coloured box will still appear, without any text next to it.

Cheers, Paschalis

Paschalis
  • 11,929
  • 9
  • 52
  • 82
  • 1
    Maybe the solution from this question will be helpful: https://stackoverflow.com/questions/58735675/creating-a-custom-legend-with-a-subset-of-data-ggplot – dc37 Nov 06 '19 at 19:38
  • 1
    This might be useful as well. https://stackoverflow.com/questions/21801950/remove-legend-entries-for-some-factors-levels –  Nov 06 '19 at 19:41
  • Thanks a lot guys. I've seen the solution. It *dont* have to create a duplicate variable though. I just have to use breaks for `scale_fill_manual` – Paschalis Nov 06 '19 at 20:04

0 Answers0