Announcement

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

  • How to draw Graph like this?

    Hi
    I have a question, How can i draw graph like this? what is the name of this graph and what is the command
    ?
    thank you.
    Attached Files
    Last edited by Javad Ebrahimzadeh; 10 Jan 2018, 03:18.

  • #2
    In Stata that would be a twoway dropline combined with smartly creating and labeling a variable for the x-axis sorted by nursing professionals within regions. For the latter you can look at various tricks discussed here: http://www.stata-journal.com/sjpdf.h...iclenum=gr0034
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Maarten gives excellent advice. I'll add what is explicit in his link -- that the countries are much, much better given horizontally.

      Comment


      • #4
        thank you for your helpful advises.this table contains part of my data.
        i can draw proper graph dot with:
        Code:
        graph dot per, over (bed) asyvars over (city) vertical
        but with twoway dropline command i have 2 problems
        1. in this command string variable like city not allowed
        2. in this command option over not allowed
        Hoping that you can help me out, thanks!
        Javad

        city bed per
        tehran icu 1
        mashad icu 0.9
        shiraz icu 0.8
        tehran ccu 1.2
        mashad ccu 1
        shiraz ccu 0.9
        tehran burn 0.9
        mashad burn 0.8
        shiraz burn 0.7

        Comment


        • #5
          This seems to me better than anything you're likely to get with twoway dropline

          Please note the use of CODE to give data examples.

          Code:
          clear 
          input str6 city    str4 bed    per
          tehran    icu    1
          mashad    icu    0.9
          shiraz    icu    0.8
          tehran    ccu    1.2
          mashad    ccu    1
          shiraz    ccu    0.9
          tehran    burn    0.9
          mashad    burn    0.8
          shiraz    burn    0.7
          end 
          replace city = proper(city) 
          
          graph dot (asis) per, over(city) over(bed) linetype(line) lines(lc(gs12) lw(vthin)) ytitle(whatever you want) ysc(alt)

          Click image for larger version

Name:	iranmed.png
Views:	1
Size:	16.4 KB
ID:	1425489

          Comment


          • #6
            Hello
            i want to plot dropline for one variable and three groups
            Please run this code
            clear
            input str3 location valueMEN valueTOT valueWOMEN
            ZAF 55.5 57.5 59.5
            RUS 66.5 71.8 77.1
            IND 66.9 68.4 69.9
            IDN 67 69.1 71.2
            LTU 69.5 74.8 80.1
            LVA 69.8 74.7 79.6
            BRA 71 74.8 78.5
            HUN 72.6 76.2 79.7
            MEX 72.9 75.4 77.9
            COL 73.1 76.2 79.4
            EST 73.3 77.8 82.2
            SVK 73.8 77.3 80.7
            POL 73.9 78 82
            CHN 74.5 76 77.5
            TUR 75.3 78 80.7
            CZE 76.1 79.1 82.1
            USA 76.1 78.6 81.1
            CHL 77.1 79.9 82.7
            CRI 77.2 79.6 82.1
            PRT 78.1 81.2 84.3
            SVN 78.2 81.3 84.3
            DEU 78.6 81.1 83.5
            FIN 78.6 81.5 84.4
            GRC 78.9 81.5 84
            DNK 79 80.9 82.8
            BEL 79 81.5 84
            FRA 79.2 82.4 85.5
            AUT 79.3 81.7 84.1
            KOR 79.3 82.4 85.4
            GBR 79.4 81.2 83
            CAN 79.8 81.9 83.9
            IRL 79.9 81.8 83.6
            NLD 80 81.6 83.2
            NZL 80 81.7 83.4
            LUX 80.1 82.8 85.4
            ISL 80.4 82.3 84.1
            AUS 80.4 82.5 84.6
            ESP 80.5 83.4 86.3
            SWE 80.6 82.4 84.1
            ISR 80.7 82.5 84.2
            NOR 80.7 82.5 84.2
            JPN 81 84.1 87.1
            ITA 81 83.3 85.6
            CHE 81.7 83.7 85.6
            end
            sort valueMEN
            seqvar axis=1/44
            labmask axis, values( location )
            twoway (dropline valueWOMEN axis, msymbol(X) xla(1/44, valuelabels ang(v) nogrid labsize(2))) ///
            (dropline valueTOT axis)(dropline valueMEN axis, msymbol(Dh)) ///
            , legend (position(6) rows(1) size(2)label(1 "Women") label(2 "Total") label(3 "Men")) ///
            yscale(range(55(5)90)) xsize(4) ysize(2) graphregion(color(white)) ///
            ytitle("Life Expectancy" (Year), size(3))xtitle("OECD Countries", size(3))
            End
            Please judge it. Do you think is it efficient? Please help me to looks it better, specially about lines and marker symbols.
            Thank you

            Comment


            • #7
              seqvar and labmask are from the Stata Journal, as you are asked (FAQ Advice #12).

              Here is your graph from #2 and my suggestion of an alternative. Complete code below


              Click image for larger version

Name:	javeh1.png
Views:	1
Size:	32.9 KB
ID:	1456707

              Click image for larger version

Name:	javeh2.png
Views:	1
Size:	38.8 KB
ID:	1456708


              Code:
              clear
              input str3 location valueMEN valueTOT valueWOMEN
              ZAF 55.5 57.5 59.5
              RUS 66.5 71.8 77.1
              IND 66.9 68.4 69.9
              IDN 67 69.1 71.2
              LTU 69.5 74.8 80.1
              LVA 69.8 74.7 79.6
              BRA 71 74.8 78.5
              HUN 72.6 76.2 79.7
              MEX 72.9 75.4 77.9
              COL 73.1 76.2 79.4
              EST 73.3 77.8 82.2
              SVK 73.8 77.3 80.7
              POL 73.9 78 82
              CHN 74.5 76 77.5
              TUR 75.3 78 80.7
              CZE 76.1 79.1 82.1
              USA 76.1 78.6 81.1
              CHL 77.1 79.9 82.7
              CRI 77.2 79.6 82.1
              PRT 78.1 81.2 84.3
              SVN 78.2 81.3 84.3
              DEU 78.6 81.1 83.5
              FIN 78.6 81.5 84.4
              GRC 78.9 81.5 84
              DNK 79 80.9 82.8
              BEL 79 81.5 84
              FRA 79.2 82.4 85.5
              AUT 79.3 81.7 84.1
              KOR 79.3 82.4 85.4
              GBR 79.4 81.2 83
              CAN 79.8 81.9 83.9
              IRL 79.9 81.8 83.6
              NLD 80 81.6 83.2
              NZL 80 81.7 83.4
              LUX 80.1 82.8 85.4
              ISL 80.4 82.3 84.1
              AUS 80.4 82.5 84.6
              ESP 80.5 83.4 86.3
              SWE 80.6 82.4 84.1
              ISR 80.7 82.5 84.2
              NOR 80.7 82.5 84.2
              JPN 81 84.1 87.1
              ITA 81 83.3 85.6
              CHE 81.7 83.7 85.6
              end
              sort valueMEN
              seqvar axis=1/44
              labmask axis, values( location )
              twoway (dropline valueWOMEN axis, msymbol(X) xla(1/44, valuelabels ang(v) nogrid labsize(2))) ///
              (dropline valueTOT axis)(dropline valueMEN axis, msymbol(Dh)) ///
              , legend (position(6) rows(1) size(2)label(1 "Women") label(2 "Total") label(3 "Men")) ///
              yscale(range(55(5)90)) xsize(4) ysize(2) graphregion(color(white)) ///
              ytitle("Life Expectancy" (Year), size(3))xtitle("OECD Countries", size(3)) name(G1) 
              
              set scheme s1color 
              rename (valueMEN valueTOT valueWOMEN ) (men all women) 
              sort men 
              gen which = _n > 22 
              graph dot (asis) men all women, by(which, title(Life expectancy (years), size(medium)) note("")) over(location, sort(1)) exclude0 linetype(line) lines(lw(vthin) lc(gs12)) ///
              marker(1, mc(blue) ms(+))  marker(2, mc(black) ms(X)) marker(3, mc(magenta) ms(Oh)) legend(row(1) pos(8)) ///
               yla(55(5)85) ysc(r(53 .)) nofill subtitle("", pos(9) nobox nobexpand) name(G2)
              All the differences boil down to removing arbitrary choices and improving readability.

              Comment

              Working...
              X