• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Can I group items in a legend in ggplot2?

Resolved: Can I group items in a legend in ggplot2?

0
By Isaac Tonny on 16/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

So I have this bar chart I made using:
For each “taxon” there is a category ‘Genome’ associated with it. I would like to group the items in the legend by ‘Genome’. Anyone know if this is possible to do? I tried to play around with the legend a
Here is reproducible data as requested!
enter image description here

Answer:

The short answer here is “no”, you can’t have grouped legends within ggplot natively.
However, the long answer is “yes, but it isn’t easy”. It requires creating a bunch of plots (one per genome) and harvesting their legends, then stitching them back onto the main plot:
enter image description here
Anyway, it’s good to know that grouped legends are at least possible in ggplot, so thanks for the OP.

If you have better answer, please add a comment about this, thank you!

ggplot2 r
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: deserializing XML list with jackson

26/03/2023

Resolved: When converting markdown to latex with pandoc, how can I end a block before the next heading?

26/03/2023

Resolved: TYPO3 SQL error: Field ‘tx_imagezoom_set’ doesn’t have a default value

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.