Created
March 13, 2017 21:47
-
-
Save bryanmayer/1bfe18dad60365d7016e7602f9963d77 to your computer and use it in GitHub Desktop.
function to extract legend from ggplot2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extract_legend = function(plot_in, theme_in = theme(legend.position = "top")) | |
gtable::gtable_filter(ggplot_gtable(ggplot_build(plot_in + theme_in)), "guide-box") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment