Hello,
I have a twoway scatter plot with confidence intervals that uses the "by" option and I'm trying to figure out a way to color individual points and confidence intervals (rather than having all points and CIs appear as the same color). When I tried separating the variables using the "separate" command I wasn't able to get the "by" option to work correctly. Any help would be much appreciated; thanks! Reproducible code and example data are below.
I have a twoway scatter plot with confidence intervals that uses the "by" option and I'm trying to figure out a way to color individual points and confidence intervals (rather than having all points and CIs appear as the same color). When I tried separating the variables using the "separate" command I wasn't able to get the "by" option to work correctly. Any help would be much appreciated; thanks! Reproducible code and example data are below.
Code:
twoway /// (rcap low high identity, horizontal) /// (scatter identity amce), by(public)
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(amce low high) byte(identity public)
. . . 1 .
. . . 2 0
-.09425743 -.13203828 -.05647658 3 0
-.07900782 -.11693051 -.04108513 4 0
. . . 5 0
. . . 6 0
.07890056 .04290051 .11490061 7 0
.07140599 .03359305 .10921893 8 0
. . . 9 0
. . . 10 0
.03607676 -.000187095 .072340615 11 0
.069494694 .03252826 .10646113 12 0
. . . 13 0
. . . 14 0
-.13493314 -.1737773 -.09608895 15 0
.04488726 .007060205 .0827143 16 0
. . . 17 0
. . . 18 0
.02542619 -.009594023 .0604464 19 0
.05704184 .02103981 .09304386 20 0
. . . 21 0
. . . 22 0
-.063884445 -.10065311 -.027115773 23 0
-.07840127 -.11685856 -.039944 24 0
. . . 25 0
. . . 26 0
-.09472065 -.13136864 -.05807268 27 0
-.11449168 -.1506369 -.07834645 28 0
. . . 1 1
. . . 2 1
-.07765516 -.10568018 -.04963013 3 1
-.05895327 -.08518407 -.032722466 4 1
. . . 5 1
. . . 6 1
.026449384 -.001082228 .053981 7 1
.023676107 -.004215147 .05156736 8 1
. . . 9 1
. . . 10 1
.07859392 .05142182 .10576602 11 1
.05168327 .024314 .07905253 12 1
. . . 13 1
. . . 14 1
-.03586419 -.063366406 -.008361971 15 1
.026215894 -.001501661 .05393345 16 1
. . . 17 1
. . . 18 1
.005194362 -.02181358 .032202303 19 1
.036742404 .009951157 .06353366 20 1
. . . 21 1
. . . 22 1
-.02104568 -.04707841 .004987055 23 1
-.02960496 -.0565303 -.002679614 24 1
. . . 25 1
. . . 26 1
-.06072497 -.08841986 -.033030078 27 1
-.04712034 -.0741455 -.02009518 28 1
end

Comment