Announcement

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

  • Merge distributional dotplots

    Hello everyone! I have the following four variables, plad, mlad, dlad and AcuteCoronarySyndromePhenotype. Plad, mlad and dlad are continuous, AcuteCoronarySyndromePhenotype is discrete with three different values. I want to merge the distribution dotplots of plad, mlad and dlad for the different values of AcuteCoronarySyndromePhenotype in the same graph (with a single y axis). Is this possible?

  • #2
    No data example here and no sign of what code you've tried. Does this help?

    Code:
    clear 
    set obs 60 
    egen cat = seq(), block(20)
    
    set seed 2803 
    
    forval j = 1/3 { 
        gen y`j' = rnormal(`j', 1)
    
        dotplot y`j', over(cat) name(G`j', replace)
    }
    
    graph combine G1 G2 G3 , row(1) ycommon

    Comment


    • #3
      Thank you very much for your message. Unfortunately, I work in a locked data shelter and therefore I cannot copy any data out. A hypothetical example of how the variables look like is the following:
      AcuteCoronarySyndromePhenotype plad mlad dlad
      0 50 13 25
      1 25 25 50
      2 75 25 0
      0 99 100 0
      1 100 100 100
      1 25 75 90
      0 75 50 99
      0 50 90 75
      0 13 13 50
      1 13 99 25
      2 25 0 13
      1 75 50 13
      2 90 75 25
      2 99 25 50
      1 75 13 90
      1 25 25 99
      1 25 75 25
      0 75 50 13
      0 99 25 50
      0 90 90 75
      2 13 75 99
      1 13 25 0
      And this is my code:
      dotplot plad mlad dlad if AcuteCoronarySyndromePhenotype==0, recast(area)
      graph save "Graph" "C:\Users\Marinos\Desktop\0lad.gph"
      dotplot plad mlad dlad if AcuteCoronarySyndromePhenotype==1, recast(area)
      graph save "Graph" "C:\Users\Marinos\Desktop\1lad.gph"
      dotplot plad mlad dlad if AcuteCoronarySyndromePhenotype==2, recast(area)
      graph save "Graph" "C:\Users\Marinos\Desktop\2lad.gph"
      This is my original command to combine:
      graph combine "C:\Users\Marinos\Desktop\0lad.gph" "C:\Users\Marinos\Desktop\1lad.gph" "C:\Users\Marinos\Desktop\2lad.gph"
      Click image for larger version

Name:	Graphinitial.png
Views:	1
Size:	31.3 KB
ID:	1539729

      And this is the command you kindly recommended:
      graph combine "C:\Users\Marinos\Desktop\0lad.gph" "C:\Users\Marinos\Desktop\1lad.gph" "C:\Users\Marinos\Desktop\2l
      > ad.gph", row(1) ycommon
      I get the following results:
      Click image for larger version

Name:	Graph.png
Views:	1
Size:	45.2 KB
ID:	1539728


      The problem, unfortunately, is not yet solved. Ideally, I would like the graphs to overlay over a common x and y-axis with different colors for the different values of AcuteCoronarySyndromePhenotype.

      Thanks again for the help!

      Comment

      Working...
      X