I'm puzzled by problem despite reading manuals and searching this forum. I'm trying to plot two lines and the percent difference between them. I need the bar plot to be first so it doesn't cover the lines, and I want it to be on the second yaxis. I also want the bar plot to have a scale for 0-100. Notably, the data is split by group, so I'm using the by() option in each plot. I'm using Stata 15.1
The command I think should work:
I also tried moving the yaxis options inside the by(), like this:
Nothing I do can get what I think should happen. The bar plot yaxis is always on the left. And its scale doesn't go from 0-100. At most I can get it to go to zero by using "base(0)".
I'm attaching a problem plot (I hope it works).

broken.gph
Sample data:
The command I think should work:
Code:
twoway (bar diff1 year, by(reg_wesp) yscale(range(0 100)) ylabel(0 (20) 100) yaxis(2)) (line gdpc_sc0 gdpc_sc1 year, by(reg_wesp))
Code:
twoway (bar diff1 year, by(reg_wesp, yscale(range(0 100)) ylabel(0 (20) 100) yaxis(2)) ) (line gdpc_sc0 gdpc_sc1 year, by(reg_wesp, yaxis(1)))
I'm attaching a problem plot (I hope it works).
broken.gph
Sample data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int year long reg_wesp float(gdpc_sc0 gdpc_sc1 diff1) 2015 1 19.475634 22.33815 14.697938 2016 1 19.3123 22.11383 14.50645 2017 1 19.45104 22.23611 14.318353 2018 1 19.600586 22.424105 14.405277 2019 1 19.63441 22.44581 14.318737 2015 2 47.26918 61.90598 30.96479 2016 2 49.40838 64.93085 31.41667 2017 2 51.57659 68.03413 31.908924 2018 2 53.62329 70.99496 32.39575 2019 2 55.26569 73.41037 32.831726 2015 3 54.85363 69.13499 26.03539 2016 3 54.80115 69.34748 26.543846 2017 3 55.58055 70.72945 27.25575 2018 3 56.9198 72.63471 27.60888 2019 3 57.87658 74.12664 28.077093 2015 4 267.81012 371.8127 38.83447 2016 4 268.7362 372.6435 38.66516 2017 4 272.0571 375.1159 37.881313 2018 4 273.46848 374.3576 36.892406 2019 4 273.30478 372.3015 36.2221 end label values reg_wesp reg_wesp label def reg_wesp 1 "Africa", modify label def reg_wesp 2 "Asia", modify label def reg_wesp 3 "CIS and Georgia", modify label def reg_wesp 4 "Developed Asia and Pacific", modify
Comment