Draw a Legend to an empty ggplot [duplicate]
问题 This question already has answers here : How to plot just the legends in ggplot2? (4 answers) Closed 2 years ago . Is it possible to create a empty ggplot with no data, but draw a legend based on defined values in R? So the image created is simply the legend? Originally I thought I could plot the data and print a white rectangle over it, but given that not every background is white, it is unrealistic. I have tried the below, but it looks like ggplot wants some dataframe, therefore I had to