Announcement

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

  • combining three twoway kdensity grapghs together

    Using the below code, I could create three nice kdensity plots. I was wondering if there is any way to combine these three graphs together. I need to combine these graphs for the sake of space when I want to display them in the word. Below also is an example code that uses auto data. I would like to end up with three plots side by side as the example code generates.
    Thanks
    Nader

    *create the density graphs
    twoway kdensity TLE_50_511 || kdensity TLE_50_512 || kdensity TLE_50_513, legend(order(1 "Married non_caregiver" 2 "Spouse caregiver <14h/w" 3 "Spouse caregiver >=14h/w")) xtitle("Total Life Expectancy (TLE)")

    twoway kdensity HLE_50_511 || kdensity HLE_50_512 || kdensity HLE_50_513, legend(order(1 "Married non_caregiver" 2 "Spouse caregiver <14h/w" 3 "Spouse caregiver >=14h/w")) xtitle("Healthy Life Expectancy (HLE)")


    twoway kdensity PLE_50_511 || kdensity PLE_50_512 || kdensity PLE_50_513, legend(order(1 "Married non_caregiver" 2 "Spouse caregiver <14h/w" 3 "Spouse caregiver >=14h/w")) xtitle("PLE (HLE/TLE)")



    *-------------------- begin example ----------------------
    // create the substantive graphs
    sysuse auto, clear
    forvalues i = 1/3 {
    scatter price mpg if rep78 == `i', name(gr`i', replace)
    }

    // combine graphs
    graph combine gr1 gr2 gr3 , ///
    rows(1) xsize(12.5) ysize(8.5)
    * t("half page of 3 figures")
    *-------------------- end example ----------------------
    Last edited by Nader Mehri; 12 Mar 2020, 22:39.

  • #2
    Doesn't this achieve what you want?

    // create the substantive graphs
    sysuse auto, clear
    forvalues i = 1/3 {
    scatter price mpg if rep78 == `i', name(gr`i', replace)
    }

    // combine graphs
    graph combine gr1 gr2 gr3 , ///
    rows(1) xsize(12.5) ysize(8.5)
    * t("half page of 3 figures")

    Comment


    • #3
      I have updated my question. This topic is continued at
      https://www.statalist.org/forums/for...em-with-legend

      Comment

      Working...
      X