Announcement

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

  • Stripplot labelling problem

    country warming humans bad
    AT 90 60 55
    BE 96 53 56
    CH 96 44 59
    CZ 86 35 48
    DE 95 54 63
    EE 90 34 45
    ES 94 57 75
    FI 94 51 52
    FR 96 47 62
    GB 93 36 52
    HU 88 45 61
    IE 95 38 50
    IS 97 55 68
    IT 91 55 53
    LT 87 30 49
    NL 96 44 44
    NO 93 38 55
    PL 90 30 52
    PT 96 48 70
    RU 76 28 37
    SE 97 51 64
    SI 96 38 59
    E~R 93 45 58

    With the above data, I can produce a stripplot with label for 1 variable but not two: E.g.,

    . stripplot humans , vert mlabel( country )


    delivers :





    But

    .stripplot humans bad , vert mlabel(country country)


    delivers :

    variable country not found
    r(111);

    Any suggestions?

  • #2
    stripplot is from SSC. You found a limitation, not to say a bug.

    I will look more into that, but the graph would have got would not have been, in my view, nearly so good as something like this:

    Code:
    clear
    input str2 country warming humans bad
    AT 90 60 55
    BE 96 53 56
    CH 96 44 59
    CZ 86 35 48
    DE 95 54 63
    EE 90 34 45
    ES 94 57 75
    FI 94 51 52
    FR 96 47 62
    GB 93 36 52
    HU 88 45 61
    IE 95 38 50
    IS 97 55 68
    IT 91 55 53
    LT 87 30 49
    NL 96 44 44
    NO 93 38 55
    PL 90 30 52
    PT 96 48 70
    RU 76 28 37
    SE 97 51 64
    SI 96 38 59
    end
    
    set scheme s1color 
    
    graph dot (asis) humans bad, over(country, sort(1) descending) exclude0 marker(1, ms(Oh)) marker(2, ms(+)) linetype(line) lines(lw(vthin) lc(gs12)) ysc(alt r(25 .)) subtitle(some good title)
    Click image for larger version

Name:	notastripplot.png
Views:	1
Size:	20.8 KB
ID:	1708928

    Comment


    • #3
      First up. why was there a problem in #1? When there are two or more outcome variables, stripplot stacks them temporarily into a longer layout, but variables not being plotted directly don't get carried along. I can think of adding an extra option to insist that this happens, but I am not so convinced it's a good idea.

      One reason: although marker label options are allowed, they aren't typically useful for most of the purposes of this command.


      You seem to have been reaching for a graph like that produced by this code:

      Code:
      clear
      input str2 country warming humans bad
      AT 90 60 55
      BE 96 53 56
      CH 96 44 59
      CZ 86 35 48
      DE 95 54 63
      EE 90 34 45
      ES 94 57 75
      FI 94 51 52
      FR 96 47 62
      GB 93 36 52
      HU 88 45 61
      IE 95 38 50
      IS 97 55 68
      IT 91 55 53
      LT 87 30 49
      NL 96 44 44
      NO 93 38 55
      PL 90 30 52
      PT 96 48 70
      RU 76 28 37
      SE 97 51 64
      SI 96 38 59
      end
      
      gen one = 1 
      gen two = 2 
      
      scatter humans one, ms(none) mla(country) mlabpos(0) || scatter bad two, ms(none) mla(country)  mlabpos(0) xlabel(1 "humans" 2 "bad", noticks) xsc(r(0.8 2.2)) aspect(1) legend(off)
      Click image for larger version

Name:	notastripplot2.png
Views:	1
Size:	16.5 KB
ID:	1708969


      So,

      1. That is some technique.

      2. I can't see that the graph is competitive with that in post #2 above. It can be improved, but there is a long way to go.

      Comment


      • #4
        Thanks. The method for the first will get me there.. but as you say with more work required. The goal was to produce something like your first suggestion, i.e.. to show relative unit positions on several variables in the same graph with labels legible. The method for the second organizes around the units not the variables which is not my main goal.

        Is there a method to assign the labels' positions at either 3 or 9 o'clock independently for each unit. (e.g., in order to be legible CZ might need to be on at 3 o'clock for humans but 9 o'clock for bad) .... maybe

        gen h_left=1 if inlist(country, countries to plot at 9oclock)
        gen h_right=1 if inlist (country, countries to plot at 3 oclock)
        gen b_left=1 if inlist(country, countries to plot at 9oclock)
        gen b_right=1 if inlist (country, countries to plot at 3 oclock)


        and then something like scatter humans one if h_left==1, ms(oh) mla(country) mlabpos(9) || scatter humans one if h_right==1, ms(oh) mla(country) mlabpos(3) || scatter bad two b_left==1, ms(oh) mla(country) mlabpos(9) || scatter bad two b_right==1, ms(oh) mla(country) mlabpos(3) xlabel(1 "humans" 2 "bad", noticks) xsc(r(0.8 2.2)) aspect(1) legend(off) I'm going to need to fix the colors but I think this is getting close

        Comment


        • #5
          I would be curious to see the results. I tried a stem-and-leaf plot as below.

          Code:
          SJ-7-3  gr0028  . . . . . . . . . . .  Speaking Stata: Turning over a new leaf
                  (help stemplot if installed)  . . . . . . . . . . . . . . .  N. J. Cox
                  Q3/07   SJ 7(3):413--433
                  discusses variants of stem-and-leaf plots using tools
                  such as scatter, by() and a new command, stemplot


          Code:
          clear
          input str2 country warming humans bad
          AT 90 60 55
          BE 96 53 56
          CH 96 44 59
          CZ 86 35 48
          DE 95 54 63
          EE 90 34 45
          ES 94 57 75
          FI 94 51 52
          FR 96 47 62
          GB 93 36 52
          HU 88 45 61
          IE 95 38 50
          IS 97 55 68
          IT 91 55 53
          LT 87 30 49
          NL 96 44 44
          NO 93 38 55
          PL 90 30 52
          PT 96 48 70
          RU 76 28 37
          SE 97 51 64
          SI 96 38 59
          end
          
          stack country humans country bad, into(country answer) clear 
          rename _stack which 
          label def which 1 humans 2 bad
          label val which which 
          set scheme s1color 
          stemplot answer, yla(35(5)75) by(which, note("")) width(2) ms(none) mla(country) aspect(2.5)
          Click image for larger version

Name:	stemplot.png
Views:	1
Size:	28.3 KB
ID:	1709032

          Comment


          • #6
            gen one=1
            gen two=2

            gen left_h=1 if inlist(cntry,"BE","SE", "IE", "NO")
            gen left_b=1 if inlist(cntry,"SE", "BE", "EE","GB","AT","CH")
            scatter humans one if left_h==1, ms(oh) mla(cntry) mlabpos(9) mlabsiz(vsmall) || scatter humans one if left_h~=1, ms(oh) mla(cntry) mlabpos(3) mlabsiz(vsmall) ||scatter ccbad two if left_b==1, ms(oh) mla(cntry) mlabpos(9) mlabsiz(vsmall) || scatter ccbad two if left_b~=1, ms(oh) mla(cntry) mlabpos(3) xlabel(1 "humans" 2 "bad", noticks) xsc(r(0.8 2.2)) ysc(r(.20 .80)) aspect(1) legend(off) mlabsiz(vsmall)


            Needs some tweaks still, but this is the idea.

            Click image for larger version

Name:	Graph.png
Views:	1
Size:	43.1 KB
ID:	1709049
            Last edited by Lyle Scruggs; 09 Apr 2023, 07:48.

            Comment


            • #7
              It's your graph and your decision, manifestly.

              In my examples I left out the last country E~R but it doesn't appear in #6 either that I can see.

              Comment

              Working...
              X