I feel like I must be missing something obvious here, but I am trying to create sets of graphs, one for each country in a panel. Not all countries have coverage for all variables, so I want to be able to use graph combine flexibly. Sometimes the final combined graph should only have two graphs, other times it may have eight graphs, but I would like for the size of the individual subgraphs to remain fixed. Right now, when there are more graphs, they start to shrink. I have tried several iterations, and I don't understand in particular why xsize() and ysize() are not solving this problem for me. Here is the current iteration
I've tried a range of different values for xsize() ysize() and iscale() and using the height and width options for graph export. I was originally hoping to save this as a pdf, so I started by trying that way as well. I tried implementing the solution described here:
https://www.statalist.org/forums/for...ne-many-graphs
I am sure that this partially boils down to me being confused by/misusing aspect ratio specifications vs dimensions, but I am just feeling a bit stumped on how to achieve this.
Code:
clear input float(ym countrycode) str28 countryname str9 countryabbr float ipi_ifs double ipi_ceic float(cpi_ifs cpi_oecd cpi_eurostat cpi_ceic urate_ifs urate_oecd) double(urate_eurostat urate_ceic) float(pmi_manufacturing pmi_services) 742 32 "Argentina" "ARG" . . . . . 33.85471 . . . . . . 743 32 "Argentina" "ARG" . . . . . 33.749226 . . . 7 . . 744 32 "Argentina" "ARG" . . . . . 33.638668 . . . . . . 745 32 "Argentina" "ARG" . . . . . 34.34842 . . . . . . 746 32 "Argentina" "ARG" . . . . . 35.528225 . . . 7 . . 747 32 "Argentina" "ARG" . . . . . 36.724083 . . . . . . 748 32 "Argentina" "ARG" . . . . . 37.764473 . . . . . . 749 32 "Argentina" "ARG" . . . . . 39.01791 . . . 6.9 . . 750 32 "Argentina" "ARG" . . . . . 41.52131 . . . . . . 751 32 "Argentina" "ARG" . . . . . 43.98238 . . . . . . 752 32 "Argentina" "ARG" . . . . . 45.36414 . . . 7.1 . . 753 32 "Argentina" "ARG" . . . . . 46.8186 . . . . . . 754 32 "Argentina" "ARG" . . . . . 48.0284 . . . . . . 755 32 "Argentina" "ARG" . . . . . 48.6635 . . . 6.3 . . 756 32 "Argentina" "ARG" . . . . . 49.70555 . . . . . . 757 32 "Argentina" "ARG" . . . . . 50.61748 . . . . . . 758 32 "Argentina" "ARG" . . . . . 51.05154 . . . 6.9 . . 759 32 "Argentina" "ARG" . . . . . 52.11509 . . . . . . 760 32 "Argentina" "ARG" . . . . . 53.32475 . . . . . . 761 32 "Argentina" "ARG" . . . . . 53.61357 . . . 6.2 . . 762 32 "Argentina" "ARG" . . . . . 53.15062 . . . . . . 708 36 "Australia" "AUS" 115.44408 . . . . 1.1741683 5.46 5.044538 . . . . 709 36 "Australia" "AUS" 114.61948 . . . . 1.4677104 5.39 4.970932 . . . . 710 36 "Australia" "AUS" 114.1041 . . . . 1.5594542 5.42 5.081361 . . . . 711 36 "Australia" "AUS" 121.01014 . . . . 1.7408124 5.28 5.220047 . . . . 712 36 "Australia" "AUS" 116.37176 . . . . 1.4563106 5.11 5.223465 . . . . 713 36 "Australia" "AUS" 121.73166 . . . . 1.3605442 5.1 5.274249 . . . . 714 36 "Australia" "AUS" 113.07336 . . . . 1.5429122 5.18 5.283499 . . . . 715 36 "Australia" "AUS" 120.39169 . . . . 1.5488868 5.27 5.270976 . . . . 716 36 "Australia" "AUS" 118.94863 . . . . 1.6393442 5.09 5.201965 . . . . 717 36 "Australia" "AUS" 115.44408 . . . . 1.725791 5.05 5.305366 . . . . 718 36 "Australia" "AUS" 117.71173 . . . . 1.732435 4.8 5.157521 . . . . 719 36 "Australia" "AUS" 121.11321 . . . . 2.1904762 4.85 5.066732 . . . . 720 36 "Australia" "AUS" 115.65023 . . . . 2.666667 5.7 5.257646 . . . . 721 36 "Australia" "AUS" 116.99021 . . . . 1.9193858 5.51 5.080297 . . . . 722 36 "Australia" "AUS" 110.70263 . . . . 2.0992367 5.56 5.206851 . . . . 723 36 "Australia" "AUS" 98.23055 . . . . .09661835 6.4 6.319729 . . . . 724 36 "Australia" "AUS" 111.01186 . . . . -.19455253 6.9 7.037285 . . . . 725 36 "Australia" "AUS" 108.64113 . . . . -.09727626 7.23 7.459805 . . . . 726 36 "Australia" "AUS" 113.38258 . . . . .7655503 7.39 7.528889 . . . . 727 36 "Australia" "AUS" 112.66106 . . . . 1.0536399 6.84 6.823338 . . . . 728 36 "Australia" "AUS" 113.89796 . . . . .3842459 6.75 6.910644 . . . . 729 36 "Australia" "AUS" 121.21629 . . . . .4770992 6.64 6.968472 . . 54.2 53.7 730 36 "Australia" "AUS" 118.12403 . . . . 1.0476191 6.36 6.823532 . . 55.8 55.1 731 36 "Australia" "AUS" 116.37176 . . . . .28490028 6.28 6.588053 . . 55.7 57 732 36 "Australia" "AUS" 119.97939 . . . . .37950665 6.85 6.318866 . . 57.2 55.6 733 36 "Australia" "AUS" . . . . . 1.0446343 6.27 5.795907 . . 56.9 53.4 734 36 "Australia" "AUS" . . . . . .7575758 5.98 5.612803 . . 56.8 55.5 735 36 "Australia" "AUS" . . . . . 2.4505184 5.51 5.423927 . . 59.7 58.8 736 36 "Australia" "AUS" . . . . . 3.2015066 4.98 5.079638 . . 60.4 58 737 36 "Australia" "AUS" . . . . . 3.3834586 4.83 4.988583 . . 58.6 56.8 738 36 "Australia" "AUS" . . . . . 2.0618556 4.6 4.699667 . . 56.9 44.2 739 36 "Australia" "AUS" . . . . . 2.4299066 4.57 4.559012 . . 52 42.9 740 36 "Australia" "AUS" . . . . . 2.982293 4.54 4.652897 . . 56.8 45.5 741 36 "Australia" "AUS" . . . . . 2.873031 5 5.245969 . . 58.2 51.8 742 36 "Australia" "AUS" . . . . . 3.136531 4.26 4.592776 . . 59.2 55.7 743 36 "Australia" "AUS" . . . . . 3.3944955 3.98 4.176357 . . 57.7 55.1 744 36 "Australia" "AUS" . . . . . 3.832117 4.51 4.150256 . . 55.1 46.6 745 36 "Australia" "AUS" . . . . . 4.7058825 4.36 4.006062 . . 57 57.4 746 36 "Australia" "AUS" . . . . . 5.376344 4.18 3.922015 . . 57.7 55.6 747 36 "Australia" "AUS" . . . . . 5.183199 3.95 3.881123 . . 58.8 56.1 748 36 "Australia" "AUS" . . . . . 5.767524 3.85 3.931803 . . 55.7 53.2 749 36 "Australia" "AUS" . . . . . 6.338028 3.47 3.588384 . . 56.2 52.6 750 36 "Australia" "AUS" . . . . . 6.730769 3.37 3.447105 . . 55.7 50.9 751 36 "Australia" "AUS" . . . . . 6.713165 3.5 3.508086 . . 53.8 50.2 752 36 "Australia" "AUS" . . . . . 6.695652 3.47 3.556266 . . 53.5 50.6 753 36 "Australia" "AUS" . . . . . 6.499134 3.26 3.422134 . . 52.7 49.3 754 36 "Australia" "AUS" . . . . . 6.872852 3.21 3.457771 . . 51.3 47.6 755 36 "Australia" "AUS" . . . . . 7.783418 3.35 3.527802 . . 50.2 47.3 756 36 "Australia" "AUS" . . . . . 6.960951 3.99 3.662857 . . 50 48.6 757 36 "Australia" "AUS" . . . . . 6.355932 3.87 3.547004 . . 50.5 50.7 758 36 "Australia" "AUS" . . . . . 5.902192 3.76 3.526662 . . 49.1 48.6 759 36 "Australia" "AUS" . . . . . 6.281407 . 3.69001 . . 48 53.7 760 36 "Australia" "AUS" . . . . . 5.214466 . 3.570811 . . 48.4 52.1 761 36 "Australia" "AUS" . . . . . 5.096074 . 3.476872 . . 48.2 50.3 762 36 "Australia" "AUS" . . . . . 4.6666665 . 3.723794 . . 49.6 47.9 740 40 "Austria" "AUT" 131.42488 120.1 3.293413 3.1883636 3.1720574 . 4.6 4.9 4.6 . 62.8 . 741 40 "Austria" "AUT" 134.86009 121.4 3.685259 3.554299 3.6273556 . 5.5 5.9 5.5 . 60.6 . 742 40 "Austria" "AUT" 137.51962 123.9 4.278607 4.1030836 3.951769 . 4.9 5.1 4.9 . 58.1 . 743 40 "Austria" "AUT" 140.84402 124.5 4.253215 4.0797324 3.650724 . 4.7 4.8 4.7 . 58.7 . 744 40 "Austria" "AUT" 144.94414 126.5 4.985045 4.748351 4.283332 . 5.3 4.7 5.3 . 61.5 . 745 40 "Austria" "AUT" 139.62508 126.2 5.753968 5.440958 5.199307 . 5.7 4.8 5.7 . 58.4 . 746 40 "Austria" "AUT" 140.5116 127.1 6.771345 6.34192 6.194915 . 4.8 4.3 4.8 . 59.3 . 747 40 "Austria" "AUT" 141.06566 125.9 7.170923 6.691096 6.669474 . 4.4 4.4 4.4 . 57.9 . 748 40 "Austria" "AUT" 141.61972 128.7 7.737512 7.181816 7.157191 . 4.4 4.7 4.4 . 56.6 . 749 40 "Austria" "AUT" 141.50891 128 8.674464 7.98205 8.025456 . 4 4.2 4 . 51.2 . 750 40 "Austria" "AUT" 136.18987 123.6 9.426628 8.614585 8.621681 . 4.3 4.6 4.3 . 51.7 . 751 40 "Austria" "AUT" 144.50087 127.6 9.320389 8.525801 8.467742 . 4.9 5.3 4.9 . 48.8 . 752 40 "Austria" "AUT" 141.06566 127.1 10.62802 9.606997 9.913309 . 4.9 5.2 4.9 . 48.8 . 753 40 "Austria" "AUT" 143.0603 126.8 11.04707 9.948062 10.35768 . 4.3 4.5 4.3 . 46.6 . 754 40 "Austria" "AUT" 142.06297 128 10.591603 9.577211 10.04671 . 5.3 5.5 5.3 . 46.6 . 755 40 "Austria" "AUT" 142.2846 126.3 10.151803 9.216199 9.534773 . 4.8 4.9 4.8 . 47.3 . 756 40 "Austria" "AUT" 145.38739 128.1 11.206078 10.076826 10.368972 . 5.7 5.1 5.7 . 48.4 . 757 40 "Austria" "AUT" 144.39006 131.8 10.8818 9.813888 9.949278 . 5.9 4.9 5.8 . 47.1 . 758 40 "Austria" "AUT" 141.28728 127.4 9.191176 8.4174595 8.441961 . 5.1 4.5 5 . 44.7 . 759 40 "Austria" "AUT" . 127.9 9.624198 8.779242 8.569448 . . 5.1 5.2 . 42 . 760 40 "Austria" "AUT" . 126.2 8.909091 8.180289 8.042442 . . 4.7 4.4 . 39.7 . 761 40 "Austria" "AUT" . 125.9 7.982063 7.392081 7.230486 . . 5.1 4.7 . 39 . 762 40 "Austria" "AUT" . 124.4 7.015986 6.556016 6.529922 . . 5.6 5.3 . 38.8 . 742 56 "Belgium" "BEL" 128.6377 124.8 5.636762 5.335972 6.623545 . 5.7 5.8 5.7 . . . end format %tm ym * Set panel xtset countrycode ym * Create pdfs of graphs of main variables of interest for each country levelsof countryname, local(countries) foreach country in `countries' { di "`country'" * Create a local to call the graphs later local countrygraphs "" preserve keep if countryname == "`country'" local abbr = countryabbr[1] summ countrycode local obs = r(N) foreach var of varlist cpi_* urate_* ipi_* pmi_* { count if missing(`var') if `obs' == r(N) continue tsline `var', title("`var'") name(`var'_`abbr') nodraw xlab(,angle(45)) local countrygraphs "`countrygraphs' `var'_`abbr'" } graph combine `countrygraphs', name(`country') cols(2) title("`country'") graphregion(color(white)) iscale(1) ysize(5) xsize(10) imargin(0 0 0 0) graph export "${figures}/tsplot_`country'.png", as(png) replace pause graph drop _all restore }
https://www.statalist.org/forums/for...ne-many-graphs
I am sure that this partially boils down to me being confused by/misusing aspect ratio specifications vs dimensions, but I am just feeling a bit stumped on how to achieve this.
Comment