Announcement

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

  • Controlling sizes of individual graphs with graph combine

    Hi, this is a dataset I am working with - it describes union density and coverage for some OECD countries for earliest available year in the 1990s and the latest available year.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str22 Country str3 CountrycodesISO int Year1 double(UD_hist1 AdjCov_hist1) int Year2 double(UD_hist2 AdjCov_hist2) float(non_missing Country_num)
    "Slovenia"           "SVN" 1991 68.4  100 2015 23.8 67.5 1  1
    "Italy"              "ITA" 1991 38.9  100 2019 32.5  100 1  2
    "Austria"            "AUT" 1995 41.1   98 2019 26.3   98 1  3
    "Belgium"            "BEL" 1995 55.7   96 2019 49.1   96 1  4
    "Iceland"            "ISL" 1993 86.5   94 2019 90.7   90 1  5
    "France"             "FRA" 1997 10.5 93.4 2013   11   98 1  6
    "Spain"              "ESP" 1991 16.6 91.1 2018   13 80.1 1  7
    "Sweden"             "SWE" 1995 84.8 90.4 2018 65.5   88 1  8
    "Denmark"            "DNK" 1993   76   83 2018 67.5   82 1  9
    "Finland"            "FIN" 1995   80   83 2017 62.9 88.8 1 10
    "Netherlands"        "NLD" 1992 24.1 82.3 2019 15.4 75.6 1 11
    "Germany"            "DEU" 1995 29.2 80.8 2018 16.6   54 1 12
    "Portugal"           "PRT" 1995 26.6 78.6 2016 15.3 77.7 1 13
    "Norway"             "NOR" 1992 58.1   75 2017   50   69 1 14
    "Australia"          "AUS" 1996 31.2   66 2018 13.7 61.2 1 15
    "Luxembourg"         "LUX" 1998 43.2   60 2018 30.4 56.9 1 16
    "New Zealand"        "NZL" 1992   36   54 2018 17.7 19.2 1 17
    "United Kingdom"     "GBR" 1993 37.5 52.7 2019 23.5 26.9 1 18
    "Slovak Republic"    "SVK" 2000 34.2   52 2015 12.6 24.4 1 19
    "Switzerland"        "CHE" 1991   23 47.7 2018 14.4   45 1 20
    "Czech Republic"     "CZE" 1994 53.2 47.5 2018 11.4 34.2 1 21
    "Hungary"            "HUN" 1993 51.5 45.1 2018  8.3 21.1 1 22
    "Canada"             "CAN" 1997 28.9 33.7 2020 27.2 31.3 1 23
    "Estonia"            "EST" 2009  7.6 32.5 2015  4.5 18.6 1 24
    "Japan"              "JPN" 1991 24.8 24.7 2019 16.8 16.8 1 25
    "Turkey"             "TUR" 1991 24.6 24.6 2019  9.9  8.5 1 26
    "Lithuania"          "LTU" 2006  9.8 19.4 2021   10 26.6 1 27
    "Korea, Republic of" "KOR" 1991 15.4 18.9 2018 11.6 14.8 1 28
    "United States"      "USA" 1991 15.5 18.1 2020 10.3 12.1 1 29
    "Chile"              "CHL" 2009 13.7 14.8 2018 16.6 20.4 1 30
    end
    label values Country_num Country_num
    label def Country_num 1 "Slovenia", modify
    label def Country_num 2 "Italy", modify
    label def Country_num 3 "Austria", modify
    label def Country_num 4 "Belgium", modify
    label def Country_num 5 "Iceland", modify
    label def Country_num 6 "France", modify
    label def Country_num 7 "Spain", modify
    label def Country_num 8 "Sweden", modify
    label def Country_num 9 "Denmark", modify
    label def Country_num 10 "Finland", modify
    label def Country_num 11 "Netherlands", modify
    label def Country_num 12 "Germany", modify
    label def Country_num 13 "Portugal", modify
    label def Country_num 14 "Norway", modify
    label def Country_num 15 "Australia", modify
    label def Country_num 16 "Luxembourg", modify
    label def Country_num 17 "New Zealand", modify
    label def Country_num 18 "United Kingdom", modify
    label def Country_num 19 "Slovak Republic", modify
    label def Country_num 20 "Switzerland", modify
    label def Country_num 21 "Czech Republic", modify
    label def Country_num 22 "Hungary", modify
    label def Country_num 23 "Canada", modify
    label def Country_num 24 "Estonia", modify
    label def Country_num 25 "Japan", modify
    label def Country_num 26 "Turkey", modify
    label def Country_num 27 "Lithuania", modify
    label def Country_num 28 "Korea, Republic of", modify
    label def Country_num 29 "United States", modify
    label def Country_num 30 "Chile", modify
    I want to create a combined graph that looks like the attached image. As I am putting them side by side, I put the categorical axis labels only on one graph. However, what this does is makes the left-side graph seem narrower than the right-side graph. I use the user-written command grc1leg2, available from SSC. Is there a way I can make these graphs look similarly sized, even though one has labels and one doesn't. This is my code:

    Code:
    graph hbar (mean) UD_hist1 AdjCov_hist1, over(Country_num, label(labsize(small))) bar(1, color(red%70)) bar(2, color(blue%70)) ylab(,labsize(small)) legend(pos(6) rows(1) size(small) label(1 "Union membership") label(2 "Collective bargaining coverage")) title(Earliest available year post-1990, size(medsmall)) name(early, replace)
    
    graph hbar (mean) UD_hist2 AdjCov_hist2, over(Country_num, axis(off)) bar(1, color(red%70)) bar(2, color(blue%70)) ylab(,labsize(small)) legend(off) title(Latest available year, size(medsmall)) name(late, replace)
    
    grc1leg2 early late, legendfrom(early) rows(1)
    Thanks for your help!
    Click image for larger version

Name:	union_density_coverage.jpg
Views:	1
Size:	118.5 KB
ID:	1763670


  • #2
    I think you're looking for the option fxsize() -- see

    Code:
    help graph combine

    I have two different takes on your interesting data -- the first I like in principle but not in practice, so I give there the code but not graph, and the second I like more in principle and in practice.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str22 Country str3 CountrycodesISO int Year1 double(UD_hist1 AdjCov_hist1) int Year2 double(UD_hist2 AdjCov_hist2) float(non_missing Country_num)
    "Slovenia"           "SVN" 1991 68.4  100 2015 23.8 67.5 1  1
    "Italy"              "ITA" 1991 38.9  100 2019 32.5  100 1  2
    "Austria"            "AUT" 1995 41.1   98 2019 26.3   98 1  3
    "Belgium"            "BEL" 1995 55.7   96 2019 49.1   96 1  4
    "Iceland"            "ISL" 1993 86.5   94 2019 90.7   90 1  5
    "France"             "FRA" 1997 10.5 93.4 2013   11   98 1  6
    "Spain"              "ESP" 1991 16.6 91.1 2018   13 80.1 1  7
    "Sweden"             "SWE" 1995 84.8 90.4 2018 65.5   88 1  8
    "Denmark"            "DNK" 1993   76   83 2018 67.5   82 1  9
    "Finland"            "FIN" 1995   80   83 2017 62.9 88.8 1 10
    "Netherlands"        "NLD" 1992 24.1 82.3 2019 15.4 75.6 1 11
    "Germany"            "DEU" 1995 29.2 80.8 2018 16.6   54 1 12
    "Portugal"           "PRT" 1995 26.6 78.6 2016 15.3 77.7 1 13
    "Norway"             "NOR" 1992 58.1   75 2017   50   69 1 14
    "Australia"          "AUS" 1996 31.2   66 2018 13.7 61.2 1 15
    "Luxembourg"         "LUX" 1998 43.2   60 2018 30.4 56.9 1 16
    "New Zealand"        "NZL" 1992   36   54 2018 17.7 19.2 1 17
    "United Kingdom"     "GBR" 1993 37.5 52.7 2019 23.5 26.9 1 18
    "Slovak Republic"    "SVK" 2000 34.2   52 2015 12.6 24.4 1 19
    "Switzerland"        "CHE" 1991   23 47.7 2018 14.4   45 1 20
    "Czech Republic"     "CZE" 1994 53.2 47.5 2018 11.4 34.2 1 21
    "Hungary"            "HUN" 1993 51.5 45.1 2018  8.3 21.1 1 22
    "Canada"             "CAN" 1997 28.9 33.7 2020 27.2 31.3 1 23
    "Estonia"            "EST" 2009  7.6 32.5 2015  4.5 18.6 1 24
    "Japan"              "JPN" 1991 24.8 24.7 2019 16.8 16.8 1 25
    "Turkey"             "TUR" 1991 24.6 24.6 2019  9.9  8.5 1 26
    "Lithuania"          "LTU" 2006  9.8 19.4 2021   10 26.6 1 27
    "Korea, Republic of" "KOR" 1991 15.4 18.9 2018 11.6 14.8 1 28
    "United States"      "USA" 1991 15.5 18.1 2020 10.3 12.1 1 29
    "Chile"              "CHL" 2009 13.7 14.8 2018 16.6 20.4 1 30
    end
    label values Country_num Country_num
    label def Country_num 1 "Slovenia", modify
    label def Country_num 2 "Italy", modify
    label def Country_num 3 "Austria", modify
    label def Country_num 4 "Belgium", modify
    label def Country_num 5 "Iceland", modify
    label def Country_num 6 "France", modify
    label def Country_num 7 "Spain", modify
    label def Country_num 8 "Sweden", modify
    label def Country_num 9 "Denmark", modify
    label def Country_num 10 "Finland", modify
    label def Country_num 11 "Netherlands", modify
    label def Country_num 12 "Germany", modify
    label def Country_num 13 "Portugal", modify
    label def Country_num 14 "Norway", modify
    label def Country_num 15 "Australia", modify
    label def Country_num 16 "Luxembourg", modify
    label def Country_num 17 "New Zealand", modify
    label def Country_num 18 "United Kingdom", modify
    label def Country_num 19 "Slovak Republic", modify
    label def Country_num 20 "Switzerland", modify
    label def Country_num 21 "Czech Republic", modify
    label def Country_num 22 "Hungary", modify
    label def Country_num 23 "Canada", modify
    label def Country_num 24 "Estonia", modify
    label def Country_num 25 "Japan", modify
    label def Country_num 26 "Turkey", modify
    label def Country_num 27 "Lithuania", modify
    label def Country_num 28 "Korea, Republic of", modify
    label def Country_num 29 "United States", modify
    label def Country_num 30 "Chile", modify
    
    twoway pcarrow UD_hist1 AdjCov_hist1 UD_hist2 AdjCov_hist2, by(Country_num) lw(thick) name(arrows)
    
    reshape long UD_hist AdjCov_hist, i(Country_num) j(Year) 
    
    label var UD_hist "Union density"
    
    label var AdjCov_hist "Collective bargaining coverage"
    
    line  *hist Year, by(Country_num, note("") imargin(small) legend(pos(12))) xtitle("") xla(1 "earliest" 2 "latest") legend(row(1)) lw(medthick ..) lp(solid dash) yla(0(25)100)
    Click image for larger version

Name:	Union_lines.png
Views:	1
Size:	94.6 KB
ID:	1763679

    Comment

    Working...
    X