I would like to define a line pattern to distinguish by race and insurance type. For example, I would like all lines corresponding to white people to be red and for Black people to be blue, and then I would like to have dashed lines by insurance type. With the code below, however, I get the error "option lcolor() not allowed)". As described in the post here: https://www.statalist.org/forums/for...or-not-allowed , I suspect this is because of my use of parentheses. Aside from creating new variables, is there anything else I can do to define line and dash colors? Thank you very much in advance!
Code:
twoway (line perc year if races == 1 & hcovtype == 1) /// (line perc year if races == 1 & hcovtype == 3) /// (line perc year if races == 1 & hcovtype == 4) /// (line perc year if races == 2 & hcovtype == 1) /// (line perc year if races == 2 & hcovtype == 3) /// (line perc year if races == 2 & hcovtype == 4), /// legend(order(1 "White, Noninsured" 2 "White, medicare or medicaid" 3 "White, other" 4 "Black, Noninsured" 5 "Black, medicare or medicaid" 6 "Black, other")) lcolor(red red red blue blue blue)
Code:
clear input int year float(races hcovtype) long hcovany float(hcovany_s totpop totraceyear perc) 2008 1 1 25287 25287 235974 235974 .10716011 2008 1 3 45182 64756 235974 235974 .27442005 2008 1 4 145931 145931 235974 235974 .6184198 2008 2 1 5157 5157 30283 30283 .17029357 2008 2 3 4464 11081 30283 30283 .3659149 2008 2 4 14045 14045 30283 30283 .4637916 2009 1 1 26543 26543 237120 237120 .1119391 2009 1 3 46342 67568 237120 237120 .28495276 2009 1 4 143009 143009 237120 237120 .6031081 2009 2 1 5357 5357 30630 30630 .1748939 2009 2 3 4702 11684 30630 30630 .3814561 2009 2 4 13589 13589 30630 30630 .44365 2010 1 1 27818 27818 238188 238188 .1167901 2010 1 3 47091 70682 238188 238188 .2967488 2010 1 4 139688 139688 238188 238188 .5864611 2010 2 1 5776 5776 31716 31716 .1821163 2010 2 3 4712 12445 31716 31716 .3923887 2010 2 4 13495 13495 31716 31716 .425495 end format %ty year label values races racesl label def racesl 1 "White", modify label def racesl 2 "Black", modify label values hcovtype hcovtypel label def hcovtypel 1 "No health insurance", modify label def hcovtypel 3 "Medicare", modify label def hcovtypel 4 "Other provider", modify
0 Response to Specifying lcolor in twoway line plot with boleans
Post a Comment