Hi,
I am encountering a problem with graph twoway bar when using the barlook-option bstyle(none) and an added xline-option. I have to use a very specific color scheme due to corporate identity rules and therefore I have to add the option bstyle(none) because otherwise graph twoway bar automatically reduces the opacity of the color. But adding bstyle(none) also has the unwanted effect that the lcolor that I specified for additional xlines, is also applied to the bars overriding the previous lcolor-command specified in the barlook-options. When bstyle(none) is not specified the color of the bar-outline is not affected by xline, but as I said, the color of the bar itself is wrong.
I also tried adding a pci-graph instead of the xline-option, but found no way to extend the vertical line without messing up my y-scale-range.
I am working with Stata 16 and a quite old revision date (26 Jun 2019) because our IT department is just now in the process of updating to a more recent revision date from Decemer 2021 (which has to be done manually because I am working from a closed network). I am not sure whether an update would already solve this problem.
I provided the following MWE and hope, somebody can help.
All the best,
Judith
I am encountering a problem with graph twoway bar when using the barlook-option bstyle(none) and an added xline-option. I have to use a very specific color scheme due to corporate identity rules and therefore I have to add the option bstyle(none) because otherwise graph twoway bar automatically reduces the opacity of the color. But adding bstyle(none) also has the unwanted effect that the lcolor that I specified for additional xlines, is also applied to the bars overriding the previous lcolor-command specified in the barlook-options. When bstyle(none) is not specified the color of the bar-outline is not affected by xline, but as I said, the color of the bar itself is wrong.
I also tried adding a pci-graph instead of the xline-option, but found no way to extend the vertical line without messing up my y-scale-range.
I am working with Stata 16 and a quite old revision date (26 Jun 2019) because our IT department is just now in the process of updating to a more recent revision date from Decemer 2021 (which has to be done manually because I am working from a closed network). I am not sure whether an update would already solve this problem.
I provided the following MWE and hope, somebody can help.
All the best,
Judith
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(F56_pc_reg HH_F56_pc) byte Region_kat double(estimate min95 max95) 80.04553009718045 81.49238777833978 1 80.04553009718045 75.08151066448116 85.00954952987975 75.24483063953524 81.49238777833978 2 75.24483063953522 69.68290072254834 80.80676055652211 73.0661247130278 81.49238777833978 3 73.06612471302779 66.1834478250159 79.94880160103968 77.87498367243218 81.49238777833978 4 77.8749836724322 73.01112735482108 82.73883999004332 82.83326719109047 81.49238777833978 5 82.8332671910903 78.45061189006448 87.21592249211612 88.93539080890999 81.49238777833978 6 88.93539080890999 85.66535599557864 92.20542562224135 87.02367994704211 81.49238777833978 7 87.023679947042 83.73579316961019 90.3115667244738 83.22867797956762 81.49238777833978 8 83.22867797956779 80.06813407339348 86.3892218857421 81.30097008597683 81.49238777833978 9 81.30097008597679 77.37832497918788 85.22361519276569 82.17560980756707 81.49238777833978 10 82.17560980756706 77.74136099353998 86.60985862159414 79.42951066370941 81.49238777833978 11 79.42951066370945 75.66902593884431 83.18999538857457 81.89068665270752 81.49238777833978 12 81.89068665270747 77.81767483989518 85.96369846551978 80.50629695053235 81.49238777833978 13 80.50629695053239 76.57196135998859 84.44063254107618 88.09331693577981 81.49238777833978 14 88.09331693577985 85.43152218759535 90.75511168396434 84.03055093288266 81.49238777833978 15 84.03055093288263 79.69051920673704 88.37058265902822 80.86403864990845 81.49238777833978 16 80.86403864990848 76.79682855673535 84.9312487430816 77.71220805509974 81.49238777833978 17 77.71220805509967 72.26485221114982 83.1595638990495 79.74670881722115 81.49238777833978 18 79.74670881722118 72.32542372774813 87.16799390669424 end label values Region_kat Regionen label def Regionen 1 "Innenstadt" 2 "Mitte Ost" 3 "Hafen/Elbe" 4 "Altona Zentrum" 5 "Altona Ost" 6 "Altona West" 7 "Eimsbüttel Süd" 8 "Eimsbüttel Nord" 9 "Winterhude/Eppendorf" 10 "Hoher Norden" 11 "Barmbek-Uhlenhorst" 12 "Wandsbek Zentrum" 13 "Wandsbek Mitte" 14 "Walddörfer" 15 "Rahlstedt" 16 "Bergedorf" 17 "Harburg Ost" 18 "Harburg West", modify format estimate %4,1f correlate F56_pc_reg Region_kat return list global n = r(N) di %9.0fc ${n} global dunkelblau `" "30 52 92" "' ***** Graphik graph twoway (bar F56_pc_reg Region_kat, yscale(range(0 100)) bstyle(none) fcolor($dunkelblau) lcolor($dunkelblau) barwidth(0.8)) /// (line HH_F56_pc Region_kat, color(cyan) lwidth(medium)) /// (rcap min95 max95 Region_kat, color(gs10)) /// (scatter F56_pc_reg Region_kat, mlabel(estimate) msymbol(none) mlabcolor(white) mlabposition(6) mlabgap(1) mlabsize(vsmall)), /// name(F56_reg_perc, replace) /// ytitle(`"Prozent "stimme eher/völl zu" "', size(small)) yscale(range(0 100)) ylabel(#5 ,labsize(small) angle(horizontal)) /// xlabel(1 "Innenstadt" 2 "Mitte Ost" 3 "Hafen/Elbe" 4 "Altona Zentrum" 5"Altona Ost" 6 "Altona West" 7 "Eimsbüttel Süd" 8 "Eimsbüttel Nord" 9 "Winterhude/Eppendorf" 10 "Hoher Norden" 11 "Barmbek-Uhlenhorst" 12 "Wandsbek Zentrum" 13 "Wandsbek Mitte" 14 "Walddörfer" 15 "Rahlstedt" 16 "Bergedorf" 17 "Harburg Ost" 18 "Harburg West", labsize(vsmall) angle(-75) ) xtitle(" ", size(tiny)) /// xline(3.5 6.5 8.5 11.5 15.5 16.5, extend lpattern(shortdash) lcolor(gray)) /// text(107 2 "Hamburg-Mitte" 107 5 "Altona" 107 7.5 "Eimsbüttel" 107 10 "Hamburg-Nord" 107 13.5 "Wandsbek" 107 16 "Bergedorf" 107 17.8 "Harburg", place(c) size(vsmall) color(gray)) /// legend(size(small) symxsize(small) keygap(1pt) bmargin(vsmall) order(3 2) label(2 "Durchschnitt HH") label(3 "Schätzungenauigkeit") rows(1) span) /// title(`" Zustimmung "Die Hamburger Polizei kümmert sich ausreichend um "' `" Anliegen/Fragen in meiner Wohngegend" (n=`:display %5.0fc ${n}') "', size(10pt) span) subtitle(" ")
Comment