Announcement

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

  • graphs - axis scale, lower limit

    This is a graph edition question.
    I have a very simple dataset. My aim is to create a bargraph with two columns (2 variables), sorted by var "averageprobsolv", by country.
    graph bar (mean) averagereading (mean) averageprobsolv, over(country, sort(averageprobsolv))

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str5 country int(averageprobsolv averagereading)
    "AUT"   506 490
    "BEL"   508 509
    "CAN"   526 523
    "CZECH" 509 493
    "DK"    497 496
    "EST"   515 516
    "FIN"   523 524
    "FR"    511 505
    "DEU"   509 508
    "IR"    498 523
    "IT"    510 487
    "JPN"   552 538
    "KOR"   561 536
    "NLD"   511 511
    "NOR"   503 504
    "POL"   481 518
    "SVK"   483 463
    "ESP"   477 486
    "SWE"   491 483
    "UK"    517 500
    "USA"   508 498
    end
    My problem is: there is only variability at the top - so my scale goes from 0 to 600, but I want my graph's scale to go from 400 to 600. When I try to change the lower limit on the stata editor it doesn't let me to set the lower limit to a value greater than 0. I wanted the variability between countries to be visible to aid the interpretation. Can anyone help me?

    Thank you,

    Marta

  • #2
    Code:
    exclude0

    Comment


    • #3
      By and large, excluding zero from bar graphs needs really good grounds, namely that a different origin is natural. That doesn't mean convenient!

      This is much discussion of this in statistical graphics literature and in statistical and graphical forums. e.g. https://stats.stackexchange.com/ques...-start-at-zero

      The data make an excellent example for the still much neglected graph dot.

      With your clear example (thanks!) I did this, which you can do too.

      Note also that horizontal layout makes even the short labels here more readable. In fact, you could use full names instead.

      Code:
      label var averagereading "Reading"
      label var averageprobsolv "Problem solving"
       
      graph dot (asis) averagereading (asis) averageprobsolv, ///
      over(country, sort(averageprobsolv)) exclude0 ///
      marker(1, ms(Oh) mcolor(red)) marker(2, ms(+) mcolor(blue)) ///
      linetype(line) lines(lc(gs12) lw(vvthin)) aspect(1)

      Click image for larger version

Name:	scores1.png
Views:	1
Size:	18.8 KB
ID:	1394747



      Here is another graph. You can't do this so easily because it is based on a program not yet public, but it might give you some ideas.
      Click image for larger version

Name:	scores2.png
Views:	1
Size:	19.4 KB
ID:	1394748




      Comment


      • #4
        Thank you,

        this looks really great. Much easier to read!

        Comment

        Working...
        X