Hi all,
I am currently using marginsplot to visualize the effects of race in a few different models. Each model excludes one race from the analysis. Because the margins include a different subset of race in each model, marginsplot assigns the colors of the markers/lines inconsistently.
For ease of comprehension and visual clarity, I would like for each racial category to show as the same color in each plot (eg NH White is red purple even though in some plots NH Black gets assigned a color first). Is there a way for me to specify before the marginsplots are created that I would like the assignment of the colors to be consistent? Worst case I suppose I could manually specify colors in each marginsplot but I'm hoping you all know of a more efficient option!
Thanks,
Eva
I am currently using marginsplot to visualize the effects of race in a few different models. Each model excludes one race from the analysis. Because the margins include a different subset of race in each model, marginsplot assigns the colors of the markers/lines inconsistently.
For ease of comprehension and visual clarity, I would like for each racial category to show as the same color in each plot (eg NH White is red purple even though in some plots NH Black gets assigned a color first). Is there a way for me to specify before the marginsplots are created that I would like the assignment of the colors to be consistent? Worst case I suppose I could manually specify colors in each marginsplot but I'm hoping you all know of a more efficient option!
Thanks,
Eva
Code:
reg politics i.race##c.age if race!=1 quietly: margins i.race, at(age=(0(20)80)) marginsplot, name(whiteout, replace) reg politics i.race##c.age if race!=2 quietly: margins i.race, at(age=(0(20)80)) marginsplot, name(blackout, replace) graph combine whiteout blackout
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(race age politics) 3 46 7 4 37 4 1 40 3 4 41 6 5 72 4 1 71 3 1 37 6 1 45 6 1 70 4 3 43 2 3 37 1 1 55 2 1 30 7 4 38 2 2 41 3 3 66 5 1 54 3 1 55 1 1 62 1 1 80 2 3 31 7 3 80 1 1 24 3 1 55 7 3 59 2 end label values race racelab label def racelab 1 "NH White", modify label def racelab 2 "NH Black", modify label def racelab 3 "Hispanic", modify label def racelab 4 "AA/NH/PI", modify label def racelab 5 "NA/AN", modify label values politics polilab label def polilab 1 "Strong Democrat", modify label def polilab 2 "Not very strong Democrat", modify label def polilab 3 "Independent-Democrat", modify label def polilab 4 "Independent", modify label def polilab 5 "Independent-Republican", modify label def polilab 6 "Not very strong Republican", modify label def polilab 7 "Strong Republican", modify
Comment