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)
Related Posts with Suppress part of legend when generating multiple twoway graphs
How can I remove spaces in string variableHello everybody! I have a string variable labelled "X", which contains a series of numerical codes …
stcox regression with unobserved heterogeneity: delayed entries or gaps detectedHello, I am studying a policy reform by using a duration model (cox proportional hazard). When I am…
Some queries about the latest sjlatexFellow Statalisters (especially StataCorp) I recently tried to update my version of sjlatex to the …
Interaction Effect Interpretation in Multiple RegressionHi! I was wondering whether someone could help me with the following, I am trying to interpret an …
Add two ICOW datasetsI am using ICOWdyadyr.dta I need a variable (io) that is located in anothet icow dataset ICOWsettle.…
Subscribe to:
Post Comments (Atom)
0 Response to Suppress part of legend when generating multiple twoway graphs
Post a Comment