I have a plot in ggplot2 with, say, 2 lines, and in the legend I have “Sharks” and “Tigers”. Is there a way I could have shark/tiger images appear in the legend instead of that text?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’re much better off using
ggsaveto save the figure as aepsorsvg, then opening it in Illustrator (or open source equivalent) and replacing the legend with the images. If you’re really dead set on doing it all in R, you can useannotation_rasterin the currentggplot2and add in some text next to it usinggeom_text. Here is a rough attempt: