superheat icon indicating copy to clipboard operation
superheat copied to clipboard

Extract Legend from Superheat

Open foreignsand opened this issue 3 years ago • 0 comments

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

foreignsand avatar Jun 23 '21 18:06 foreignsand