rlbarter / superheat

An r package for generating beautiful and customizable heatmaps
https://rlbarter.github.io/superheat/
235 stars 29 forks source link

Extract Legend from Superheat #59

Open foreignsand opened 3 years ago

foreignsand commented 3 years ago

I'm using grid.arrange to plot a number of heat maps in a grid. I would like for them to then only have one legend and would like to be able to extract the legend from a superheat instance in order to plot it. Is there a way to do this?

I've tried a number of things, for example:

p = superheat(mtcars,
          # change the size of the labels
          left.label.size = 0.4,
          bottom.label.size = 0.1)

p$legend

or

p = superheat(mtcars,
          # change the size of the labels
          left.label.size = 0.4,
          bottom.label.size = 0.1)

p_legend = p$plot

p_legend$legend

But I've exhausted my options at this point.

Any help would be much appreciated!

Cheers, Emily