Announcement

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

  • issue with plotting

    Using the code below, I have created the plot below. I wonder how can the TLE values can be added to the top of the bars. Also, I wonder how the number at the beginning of the labels for the y-axis can be removed (i.e., 1.US-born --> US-born)
    Thanks,
    Nader

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte age str2 sample_ str1 sex float(Underweight Healthy Overweight Obese TLE) str3 profile str14 birth_place str20 race float(PUWLE PHWLE POWLE POBLE)
    50 "01" "F" .6815519  9.853015 10.017346  10.48322 31.035133 "F01" "1.US-born"      "0.non-Hispanic White" 2.2 31.7 32.3 33.8
    50 "02" "F" .8893277   12.3277 10.886005  9.213534 33.316566 "F02" "2.Foreign-born" "0.non-Hispanic White" 2.7   37 32.7 27.7
    50 "11" "F" .3959603  4.651466  8.812572 14.597174  28.45717 "F11" "1.US-born"      "1.non-Hispanic Black" 1.4 16.3   31 51.3
    50 "12" "F" .5641846  6.300639  10.17347 13.738186  30.77648 "F12" "2.Foreign-born" "1.non-Hispanic Black" 1.8 20.5 33.1 44.6
    50 "21" "F"  .487384  7.625911 11.330256 12.928034 32.371586 "F21" "1.US-born"      "2.Hispanic"           1.5 23.6   35 39.9
    50 "22" "F" .6501698  9.679329 12.451668 11.706597 34.487762 "F22" "2.Foreign-born" "2.Hispanic"           1.9 28.1 36.1 33.9
    50 "31" "F" .7672865  10.38339  9.695418  9.867319 30.713415 "F31" "1.US-born"      "3.non-Hispanic other" 2.5 33.8 31.6 32.1
    50 "32" "F" .9929502 13.045523 10.563076  8.598753 33.200302 "F32" "2.Foreign-born" "3.non-Hispanic other"   3 39.3 31.8 25.9
    end

    graph hbar (asis) Underweight Healthy Overweight Obese , stack over(birth_place) over(race) name(G3, replace)
    Click image for larger version

Name:	G3.png
Views:	1
Size:	60.1 KB
ID:	1715316


  • #2
    I wonder how can the TLE values can be added to the top of the bars.
    I think you'd need to use the Graph Editor.

    Aside: How can the total of these categories differ by race or birth place?


    Also, I wonder how the number at the beginning of the labels for the y-axis can be removed (i.e., 1.US-born --> US-born)
    Code:
    help numlabel
    Last edited by Nick Cox; 29 May 2023, 01:38.

    Comment


    • #3
      Is there any way to change the x bar scale such that the intervals become 5 instead of 10 for example!

      Comment


      • #4
        You're referring to the y axis. See help graph bar:

        graph hbar draws horizontal bar charts. In a horizontal bar chart, the numerical axis is still called the y axis, and the categorical axis is still called the x axis, but y is
        presented horizontally, and x vertically.


        Hence the option yla(0(5)35) or yla(0(5)40) should help.

        Comment

        Working...
        X