You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
baptiste edited this page Sep 2, 2010
·
11 revisions
Share a legend between two ggplot2 graphs
Goal: align two plots, and place one or two legends on the side.
It is sometimes possible to obtain good results by creating a dummy facetting of the data as in Align-two-plots-on-a-page. For greater control, you can also use Grid to place the plots and the legends in an arbitrary layout,
Idea:
create your two plots p1 and p2
save the legend of p1 as a separate grob,
strip the legend of p1 and p2,
create three viewports on the page and print p1, p2, p3.