Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • color/line pattern for graph?

    Dear All, I found the following code
    Code:
    sysuse auto, clear
    regress price c.length##c.mpg 
    est store regression   
    
    foreach v of var length mpg {
      sum `v' if e(sample)
      local low_`v' = r(mean)-r(sd)
      local high_`v' = r(mean)+r(sd)
    }
    
    margins, at(mpg=(`low_mpg' `high_mpg') length=(`low_length' `high_length')) 
    marginsplot, xlabel(13 " " `low_mpg' "Low IV" `high_mpg' "High IV" 30 " ") ///
       ytitle("Price") ylabel(2000(1000)9000, angle(0) nogrid) ///
       legend(position(3) col(1) stack) title("") noci
    with graph
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	74.2 KB
ID:	1513687


    My question is:
    1. How can I change the colors of lines?
    2. How can I obtain, say, a dash and/or dot line?
    3. Instead of circle, how can I obtain, say square symbol? Thanks in advance!
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)

  • #2
    Dear All, I found the option `plot1opts' does the trick as follows.
    Code:
    regress price c.length##c.mpg 
    est store regression   
    
    foreach v of var length mpg {
      sum `v' if e(sample)
      local low_`v' = r(mean)-r(sd)
      local high_`v' = r(mean)+r(sd)
    }
    
    margins, at(mpg=(`low_mpg' `high_mpg') length=(`low_length' `high_length')) 
    marginsplot, xlabel(13 " " `low_mpg' "Low IV" `high_mpg' "High IV" 30 " ") ///
       ytitle("Price") ylabel(2000(1000)9000, angle(0) nogrid) ///
       legend(position(3) col(1) stack) title("") noci ///
       plot1opts(m(Oh) lp(dash)) plot2opts(m(square) lp(dot))
    Click image for larger version

Name:	Graph1.png
Views:	1
Size:	67.9 KB
ID:	1513690
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)

    Comment


    • #3
      I think ssc command -grstyle- offers convenient way to edit graphs. Check this example page: http://repec.sowi.unibe.ch/stata/grs...style-set.html

      Comment


      • #4
        Dear JeongHoon, Thanks for the suggestion. I will have a look.

        Ho-Chuan (River) Huang
        Stata 19.0, MP(4)

        Comment

        Working...
        X