Hi all,
I'm a long-time reader, first-time poster. Thanks in advance for advice!
I would like to superimpose a scatter plot and a line graph. In the legend, I'd like to label the scatter, but not the line. For example, this graph shows what I'd like to keep and what I'd like to suppress:
sysuse auto, clear
tab foreign, nol
sysuse auto, clear
reg price mpg if foreign
predict phat_f
reg price mpg if foreign==0
predict phat_d
twoway (scatter price mpg if foreign, mc(red) ytitle("Price") legend(label(1 "Foreign - keep this"))) ///
(scatter price mpg if foreign==0, mc(blue) legend(label(2 "Domestic - and this"))) ///
(line phat_f mpg, sort lc(red) legend(label(3 "Don't want this"))) ///
(line phat_d mpg, sort lc(blue) legend(label(4 "or this")))
My workaround has been to turn off the entire legend and add text within the plot region, but I'd like to know better.
Thanks again,
Bill
(using Stata 15)
I'm a long-time reader, first-time poster. Thanks in advance for advice!
I would like to superimpose a scatter plot and a line graph. In the legend, I'd like to label the scatter, but not the line. For example, this graph shows what I'd like to keep and what I'd like to suppress:
sysuse auto, clear
tab foreign, nol
sysuse auto, clear
reg price mpg if foreign
predict phat_f
reg price mpg if foreign==0
predict phat_d
twoway (scatter price mpg if foreign, mc(red) ytitle("Price") legend(label(1 "Foreign - keep this"))) ///
(scatter price mpg if foreign==0, mc(blue) legend(label(2 "Domestic - and this"))) ///
(line phat_f mpg, sort lc(red) legend(label(3 "Don't want this"))) ///
(line phat_d mpg, sort lc(blue) legend(label(4 "or this")))
My workaround has been to turn off the entire legend and add text within the plot region, but I'd like to know better.
Thanks again,
Bill
(using Stata 15)
Comment