Announcement

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

  • Graph hbar for multiple variables in the x-axis

    Hi Everyone,

    I am having difficulty plotting an hbar for multiple variables in the x-axis either with -graph- or -catplot- similar to the attached Figure. More precisely, I would like to plot five variables (ABC, ADOWA, XYZ, WERU, and WBGREAT) over the county (the variable is called Province). Thus, in the y-axis we have the county and x-axis is the five variables. The five variables are embedded to the Dimensions variable, and the variables Proportion is the proportion in each county. I first reshaped the data set to the long format and endeavor to use -graph- but I did not succeed. Below is the data :


    ----------------------- copy starting from the next line -----------------------
    [CODE]

    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str17 Province str19 Dimensions double prop float Proportion
    "Barh El Gazal" "WERU" 89.34236907958984 89
    "Barh El Gazal" "ABC" 62.812477111816406 63
    "Barh El Gazal" "ADOWA" 94.82465362548828 95
    "Barh El Gazal" "XYZ" 53.065792083740234 53
    "Barh El Gazal" "WBGREAT" 98.91114044189453 99
    "Batha" "WERU" 95.84200286865234 96
    "Batha" "ABC" 56.73033905029297 57
    "Batha" "ADOWA" 92.83163452148438 93
    "Batha" "XYZ" 68.12935638427734 68
    "Batha" "WBGREAT" 99.10173034667969 99
    "Borkou" "WERU" 83.75558471679688 84
    "Borkou" "ABC" 66.74628448486328 67
    "Borkou" "ADOWA" 98.24359130859375 98
    "Borkou" "XYZ" 92.6272964477539 93
    "Borkou" "WBGREAT" 98.12161254882813 98
    "Chari Baguirmi" "WERU" 86.19207000732422 86
    "Chari Baguirmi" "ABC" 57.94179153442383 58
    "Chari Baguirmi" "ADOWA" 96.10115814208984 96
    "Chari Baguirmi" "XYZ" 67.17070007324219 67
    "Chari Baguirmi" "WBGREAT" 98.73426818847656 99
    "Ennedi Est" "WERU" 96.72649383544922 97
    "Ennedi Est" "ABC" 59.52171325683594 60
    "Ennedi Est" "ADOWA" 97.82662200927734 98
    "Ennedi Est" "XYZ" 93.61170196533203 94
    "Ennedi Est" "WBGREAT" 99.18461608886719 99
    "Ennedi Ouest" "WERU" 94.89917755126953 95
    "Ennedi Ouest" "ABC" 63.36820602416992 63
    "Ennedi Ouest" "ADOWA" 96.35868072509766 96
    "Ennedi Ouest" "XYZ" 86.37265014648438 86
    "Ennedi Ouest" "WBGREAT" 97.64796447753906 98
    "Guera" "WERU" 89.5811767578125 90
    "Guera" "ABC" 56.673988342285156 57
    "Guera" "ADOWA" 92.70738220214844 93
    "Guera" "XYZ" 52.570343017578125 53
    "Guera" "WBGREAT" 98.1112289428711 98
    "Hadjer Lamis" "WERU" 90.28373718261719 90
    "Hadjer Lamis" "ABC" 62.78675079345703 63
    "Hadjer Lamis" "ADOWA" 86.46724700927734 86
    "Hadjer Lamis" "XYZ" 55.14447021484375 55
    "Hadjer Lamis" "WBGREAT" 98.5306167602539 99
    "Kanem" "WERU" 94.92951965332031 95
    "Kanem" "ABC" 64.66179656982422 65
    "Kanem" "ADOWA" 94.28390502929688 94
    "Kanem" "XYZ" 77.52328491210938 78
    "Kanem" "WBGREAT" 100 100
    "Lac" "WERU" 95.43218994140625 95
    "Lac" "ABC" 66.28245544433594 66
    "Lac" "ADOWA" 98.28605651855469 98
    "Lac" "XYZ" 62.219200134277344 62
    "Lac" "WBGREAT" 99.83283996582031 100
    "Logone Occidental" "WERU" 93.07112121582031 93
    "Logone Occidental" "ABC" 53.22652816772461 53
    "Logone Occidental" "ADOWA" 87.78823852539063 88
    "Logone Occidental" "XYZ" 65.7930908203125 66
    "Logone Occidental" "WBGREAT" 98.47350311279297 98
    "Logone Oriental" "WERU" 93.4299545288086 93
    "Logone Oriental" "ABC" 47.587337493896484 48
    "Logone Oriental" "ADOWA" 89.2779312133789 89
    "Logone Oriental" "XYZ" 71.6064682006836 72
    "Logone Oriental" "WBGREAT" 99.72823333740234 100
    "Mandoul" "WERU" 97.46295166015625 97
    "Mandoul" "ABC" 46.71428680419922 47
    "Mandoul" "ADOWA" 79.70826721191406 80
    "Mandoul" "XYZ" 55.84461212158203 56
    "Mandoul" "WBGREAT" 99.7596435546875 100
    "Mayo Kebbi Est" "WERU" 90.16718292236328 90
    "Mayo Kebbi Est" "ABC" 51.01268005371094 51
    "Mayo Kebbi Est" "ADOWA" 95.92758178710938 96
    "Mayo Kebbi Est" "XYZ" 51.96967697143555 52
    "Mayo Kebbi Est" "WBGREAT" 99.38680267333984 99
    "Mayo Kebbi Ouest" "WERU" 92.79168701171875 93
    "Mayo Kebbi Ouest" "ABC" 54.830718994140625 55
    "Mayo Kebbi Ouest" "ADOWA" 96.71868896484375 97
    "Mayo Kebbi Ouest" "XYZ" 62.85404968261719 63
    "Mayo Kebbi Ouest" "WBGREAT" 98.28685760498047 98
    "Moyen Chari" "WERU" 90.73213958740234 91
    "Moyen Chari" "ABC" 42.006221771240234 42
    "Moyen Chari" "ADOWA" 91.65740966796875 92
    "Moyen Chari" "XYZ" 58.81248474121094 59
    "Moyen Chari" "WBGREAT" 97.6261215209961 98
    "Ndjamena" "WERU" 44.49864959716797 44
    "Ndjamena" "ABC" 43.46933364868164 43
    "Ndjamena" "ADOWA" 77.47868347167969 77
    "Ndjamena" "XYZ" 63.03280258178711 63
    "Ndjamena" "WBGREAT" 72.9898681640625 73
    "Ouaddaï" "WERU" 88.9566650390625 89
    "Ouaddaï" "ABC" 61.86035919189453 62
    "Ouaddaï" "ADOWA" 95.45416259765625 95
    "Ouaddaï" "XYZ" 67.04611206054688 67
    "Ouaddaï" "WBGREAT" 92.57655334472656 93
    "Salamat" "WERU" 86.14173889160156 86
    "Salamat" "ABC" 56.16421127319336 56
    "Salamat" "ADOWA" 97.0260238647461 97
    "Salamat" "XYZ" 71.4294204711914 71
    "Salamat" "WBGREAT" 98.7117919921875 99
    "Sila" "WERU" 92.73976135253906 93
    "Sila" "ABC" 60.39995574951172 60
    "Sila" "ADOWA" 96.19384765625 96
    "Sila" "XYZ" 64.51737976074219 65
    "Sila" "WBGREAT" 99.08551788330078 99
    end


    I tried this code:

    graph dot (asis) Proportion , over(Dimensions) over(Province) asyvars exclude0 ///
    legend(pos(3) col(1)) marker(1, ms(Oh)) marker(2, ms(X)) ///
    marker(3, ms(+)) marker(4, ms(Dh)) marker(5, ms(Sh)) linetype(line) ///
    lines(lc(gs12) lw(thin))

    But, it is not similar to the attached figure. For instance, I want five variables to be displayed in the x-axis with their respective values in the horizontal bar.

    I would appreciate your value inputs.

    Thanks
    Attached Files
Working...
X