Announcement

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

  • How can I change the scale of the y-axis in a Barchart


    Hello,

    I would be very grateful if someone could help me with the scale of the y-axis of my barchart (please find it attached to this post).

    Since the average values of the y-axis are all above 800, I wanted to re-scale the range with a min. of 600 and max. of 1,100 (just so it looks better).

    The command I used was:
    Code:
    graph bar (mean) lnexpy, over(country, sort(lnexpy) label(labsize(small))) /// 
    blabel(bar, size(small)) ytitle(Average lnexpy) ///
    ytitle(, size(small)) title(Average Export Sophistication)
    Would be great if you could help,
    Thank you and best regards,
    Julie
    Attached Files

  • #2
    First of all, your variable is in logs, so a bar chart does not make sense. Even if you specify that the minimum value be 600, you could also have specified some other value such as 100. Since we use bar charts to compare heights of bars, starting points will greatly influence perceptions of differences between heights. It is accepted that bar charts start at 0 (or at least, the reference point is 0), which leads to no ambiguity if this is the case. But this starting point cannot work for a logarithmic scale. Therefore, look at other graphs such as dot charts.
    Last edited by Andrew Musau; 08 May 2020, 08:55.

    Comment


    • #3
      I agree with @Andrew Musau's general notion that bar charts are dubious for data on logarithmic scales, but the typical value of the variable plotted is around 1000. So if what are shown are natural logarithms, then the original values were around exp(1000), which I find hard to believe. So the prefix ln I guess arises for other reasons.

      Here is the graph shown properly as .png -- as we ask explicitly in FAQ Advice #12 -- not as a .gph attachment, which is more awkward.







      With a range from 896 to 1003 on whatever scale it is (who can interpret the first decimal place?) I suggest instead a dot chart -- and horizontal alignment for better readability


      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str15 country float lnexpy
      "Brunei"       954
      "Cambodia"     896
      "Indonesia"    961
      "Laos"         929
      "Malaysia"     986
      "Myanmar"      936
      "Philippines"  966
      "Singapore"   1003
      "Thailand"     982
      "Vietnam"      965
      end
      
      graph dot (asis) lnexpy, over(country, sort(lnexpy) label(labsize(small))) blabel(bar, size(small)) ytitle("") title(Average Export Sophistication) exclude0 ///
      linetype(line) lines(lc(gs12) lw(vthin)) ysc(alt r(880 1020)) scheme(s1color)
      
      .


      Much hinges on personal taste, but I also suggest that the ytitle() in #1 is redundant given the much clearer title.


      Click image for larger version

Name:	exports.png
Views:	1
Size:	23.5 KB
ID:	1551992

      Comment


      • #4
        but the typical value of the variable plotted is around 1000. So if what are shown are natural logarithms, then the original values were around exp(1000), which I find hard to believe.
        Good point Nick. The graph in #1 is not visible in your post, so I upload it here.

        Click image for larger version

Name:	Barchart_averagelnexpy.png
Views:	1
Size:	47.0 KB
ID:	1552010

        Comment


        • #5
          I can see it....

          Comment


          • #6
            Because it is saved somewhere on your PC. This happens sometimes with uploading graphs to the forum. Try your smart phone or another PC.

            Comment


            • #7
              Dear both,

              Thank you so much for your help!

              Sorry for attaching it as a .gph attachment!

              The original values of EXPY were actually around exp(1000). That was one of the main reasons why I've chosen to use the natural logarithm.

              Thanks again!
              Julie

              Comment


              • #8
                I can see it on my smart phone too.

                Comment


                • #9
                  That is odd. This is what I see.
                  Click image for larger version

Name:	Untitled.png
Views:	1
Size:	114.9 KB
ID:	1552030

                  Comment

                  Working...
                  X