Announcement

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

  • Trouble controlling colors, shapes, & tick mark locations for a series of 2 means in coefplot

    This is similar to my last post here, but different in that I am attempting to visualize two means at once, each for a series of locations. I want the locations to be noted with a tick mark and label below each respective set of means. The means should be stationed vertically above one another, OR offset slightly with the location tick mark & label positioned directly in between the two. I want 1 set of means (m1-m3 in the example below) to be one color, and one set of means (M1-M3 below) to be another color. I ALSO want to be able to control the shape of the markers. While I'm further along after Andrew's help with the last problem, I still can't figure this out. Maybe it's not possible to do with coefplot? Thoughts/code appreciated.

    Reproducible example below. Note on what is right / is not right shown here.
    Code:
    clear matrix
    sysuse auto , clear 
    xtile p3=price, nquantiles(3)
    forval i=1/3 {
        qui mean weight if p3==`i'
        estimate store m`i'
    }
    forval i=1/3 {
        preserve 
            gen e = rnormal(0,500)
            replace weight = weight+e+1000
            qui mean weight  if p3==`i'
        restore 
        estimate store M`i'
    }
    coefplot (m1 M1, mc(navy orange) ciopts(color(navy orange))) ///
        (m2 M2, mc(navy orange) ciopts(color(navy orange) msymbol(t))) ///
        (m3 M3, mc(navy orange) ciopts(color(navy orange))) , ///
        vert swapnames asequation ///
        eqrename(m1= "First location" M1="First location" ///
            m2= "Second location" M2="Second location" ///
            m3= "Third location" M3="Third location") ///
        xlabel(, angle(45)) ytitle("Blah") ///
        legend(order(2 "Label for circles" 4 "Label for squares")) ///
        graphregion(color(white)) ciopts(color(navy))

  • #2
    Code:
    clear matrix
    sysuse auto , clear 
    xtile p3=price, nquantiles(3)
    forval i=1/3 {
        qui mean weight if p3==`i'
        estimate store m`i'
    }
    forval i=1/3 {
        preserve 
            gen e = rnormal(0,500)
            replace weight = weight+e+1000
            qui mean weight  if p3==`i'
        restore 
        estimate store M`i'
    }
    coefplot (M1, mc(orange) offset(0) ciopts(color(orange))) ///
        (M2, mc(orange) offset(0) ms(s) ciopts(color(orange))) ///
        (M3, mc(orange) offset(0) ciopts(color(orange))) ///
        (m1, mc(navy) offset(0) ciopts(color(navy) msymbol(t))) ///
        (m2, mc(navy) offset(0) ms(s) ciopts(color(navy) msymbol(t))) ///
        (m3, mc(navy) offset(0) ciopts(color(navy) msymbol(t))), ///
        vert swapnames asequation norecycle ///
        eqrename(m1= "First location" M1="First location" ///
            m2= "Second location" M2="Second location" ///
            m3= "Third location" M3="Third location") ///
        xlabel(, angle(45)) ytitle("Blah") ///
        legend(order(8 "Label for circles" 4 "Label for squares")) ///
        graphregion(color(white)) ciopts(color(navy))
    Res.:

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	46.0 KB
ID:	1689316

    Comment


    • #3
      Genius. I should have realized that it's the joint equation name that puts them above one another. Thank you!

      Comment

      Working...
      X