Announcement

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

  • Overlay bar graph with two symbols (and two y-axes

    Hello all,

    I'm trying to replicate this graph shown below:

    Click image for larger version

Name:	Share_of_Employment.png
Views:	1
Size:	20.5 KB
ID:	1525534


    My data is as follows (not sure why there all the missing values there):


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str39 Occupations double ShareofEmploymentinShortage str17 AverageShortageIntensity double AverageSurplusIntensity byte(E F G H I J K L M N O P Q R S T)
    "Managers"                                 81.81818181818183 ".4099444444444444"              -.4615 . . . . . . . . . . . . . . . .
    "Professionals"                            59.57446808510638 "0.550"             -.35757894736842105 . . . . . . . . . . . . . . . .
    "Technicians and Associate Professionals" 54.761904761904766 ".5661666666666666" -.24071428571428571 . . . . . . . . . . . . . . . .
    "Clerical Support Workers"                 66.66666666666666 ".42875"            -.22837500000000002 . . . . . . . . . . . . . . . .
    "Service and Sales Workers"                           59.375 ".2842631578947368" -.27538461538461534 . . . . . . . . . . . . . . . .
    "Skilled Agricultural Workers"             39.58333333333333 ".4716842105263158"  -.3427142857142857 . . . . . . . . . . . . . . . .
    "Plant and Machine Operators"                             50 ".481"              -.23969999999999997 . . . . . . . . . . . . . . . .
    "Elementary Occupations"                  14.814814814814813 ".44125"            -.36013043478260875 . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    ""                                                         . ""                                    . . . . . . . . . . . . . . . . .
    end
    I got as far as this (which is not to say very far!)

    Code:
    twoway (bar ShareofEmploymentinShortage, over(Occupations) yaxis(1)) (dot AverageShortageIntensity AverageShortageIntensity , over( Occupations) yaxis(2))
    I'd be grateful for your assistance!

  • #2
    Most of those observations and variables don't seem very interesting....

    More crucially, I am puzzled by your code as it isn't, I think, even legal. over() is not supported as an option by twoway bar or twoway dot. If code doesn't work, you can and should say so.

    One of your numeric variables is string and requires major surgery.

    This is not what you asked for. Showing quite different scales on a graph makes many people feel very queasy and your data is even messier than implied by the example plot as one variable is entirely negative.

    Here I used multidot (SSC) as explained at https://www.statalist.org/forums/for...ailable-on-ssc

    I don't understand what any of these variables really mean, so my abbreviations may miss the mark, but that's in your hands.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str39 Occupations double ShareofEmploymentinShortage str17 AverageShortageIntensity double AverageSurplusIntensity 
    "Managers"                                 81.81818181818183 ".4099444444444444"              -.4615 
    "Professionals"                            59.57446808510638 "0.550"             -.35757894736842105 
    `""Technicians and" "Associates""' 54.761904761904766 ".5661666666666666" -.24071428571428571 
    `""Clerical" "Support""'                  66.66666666666666 ".42875"            -.22837500000000002 
    `""Service" "and Sales""'                           59.375 ".2842631578947368" -.27538461538461534 
    `""Skilled" "Agricultural""'             39.58333333333333 ".4716842105263158"  -.3427142857142857 
    `""Plant and Machine" "Operators""'                             50 ".481"              -.23969999999999997 
    `""Elementary""Occupations""'                  14.814814814814813 ".44125"            -.36013043478260875 
    end
    
    destring AverageShortageIntensity, replace  
    label var Share `""Employment" "share, %""' 
    label var AverageSh `""Shortage" "intensity""'   
    label var AverageSu `""Surplus" "intensity""' 
    gen which = 9-_n 
    set scheme s1color 
    multidot Share AverageSh AverageSu, over(Occ) sort(which) by(compact row(1)) recast(bar) ytitle("") bfcolor(green*0.1)

    Click image for larger version

Name:	rooney.png
Views:	1
Size:	26.9 KB
ID:	1525587



    Comment

    Working...
    X