Hello,
I’m using Stata BE/17.0. I want to overlay a twoway graph from data A over an histogram from data B (or vice-versa). I want the final figure to have two y axis. My intuition is that I would need to have my info in only one dataset. Is it feasible with two separate datasets using a saved graph/histogram? Any suggestions?
Data A (twoway graph):
Code for the two-way graph, where y axis is an estimate of a program return in a school subject and x axis values are numbers of days of participation to the program:
Dataset B (histogram):
Code for the histogram, where y axis is a proportion in percentage and x axis values are numbers of days of participation to the program:
Thank you for your help,
Nicolas Charette
I’m using Stata BE/17.0. I want to overlay a twoway graph from data A over an histogram from data B (or vice-versa). I want the final figure to have two y axis. My intuition is that I would need to have my info in only one dataset. Is it feasible with two separate datasets using a saved graph/histogram? Any suggestions?
Data A (twoway graph):
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float duree double(estimate min95 max95) 30 -.39709141041976465 -1.7826537251028372 .9884709042633077 60 -.39709141041976465 -1.7826537251028372 .9884709042633077 90 -.45052648862218997 -1.8140828455056424 .9130298682612623 120 -.5234470219012863 -1.7725581317823662 .7256640879797935 150 -.5234470219012863 -1.7725581317823662 .7256640879797935 180 -.5646014010734139 -1.9337486345279202 .8045458323810923 210 -.790618265194683 -2.1615262120481495 .5802896816587834 240 -.7445110715021096 -1.9676471592732083 .47862501626898923 270 -.9396592958036535 -2.1593530138289143 .28003442222160746 end
Code:
twoway (scatter estimate duree,legend(region(col(white))) yscale(titlegap(2)) xscale(range(0 300) titlegap(2)) msymbol(square) msize(small)) (rcap min95 max95 duree, lcolor(blue)), xlabel(0(30)300, valuelabels angle(0) labsize(small)) xtitle("Number of days") ytitle("Grade variation (%)") ysca(titlegap(2)) ylab(, labs(small)) xsca(titlegap(2)) yline(0, lcolor(red)) graphregion(color(white))
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id jours) 6 214 35 181 41 225 51 207 58 206 63 184 68 227 77 150 80 165 102 64 131 241 136 261 140 177 162 192 163 76 166 236 176 157 185 106 209 87 213 269 237 83 266 239 277 10 359 191 360 191 373 97 end
Code:
histogram jours if jours>0 & jours<270, xscale(range(0 300)) percent fcolor(bluishgray) ytitle(Proportion (%)) title(Proportion of students in the program by days of participation) xlabel(0(30)300) bin (10) name(jours, replace)
Thank you for your help,
Nicolas Charette
Comment