How to add a legend when combining graphs

How to add a legend when combining graphs

by Armaiti Mody -
Number of replies: 3

Hi,

For my figure, I've combined two box plots onto the same figure side by side (as each plot has a different unit scale for the y-axis).  While I have been able to labels all the y and x-axis on both plots, I keep getting an error when I try to put in a legend after I've combined the two plots.  Do I need to create a legend in one of my box plots before I combine them? 

I'm using the following code but haven't been successful:

legend(label(1 "Caucasian") label(2 "Non-Caucasian"))

Also, I can't seem to change to colors of the two sets of box plots I've created.  Can I change the colors of the boxes even after I've combined the graphs?

Thanks so much for your help!

Armaiti

In reply to Armaiti Mody

Re: How to add a legend when combining graphs

by Kristen -

You would need to change the colors before using graph combine. 


Have you tried using the grc1leg package to combine the plots? You create a legend and then grc1leg combines them and keeps the legend from the first plot. 

ssc install grc1leg

help grc1leg

In reply to Kristen

Re: How to add a legend when combining graphs

by Salem Kamalay -

The grc1leg package appears to have been removed from the STATA website. Do you know if there's another way to install this? Any other way to combine legends? Thanks!

UPDATE: I was able to install it using "search grc1leg"

In reply to Salem Kamalay

Re: How to add a legend when combining graphs

by Kristen -
Yes, you need to "net install" it instead of "ssc install" it like this: 


net install grc1leg, from(http://www.stata.com/users/vwiggins)