Hi everyone,
I would like to obtain a stack bar graph, but with frequencies on the y-axis that sum to 100% for each province, in order to have a better view of the different provinces.
I have produced a plot, but the y-axis does not show frequencies. Instead, it is the mean that is plotted.
Here is the graph:

Could anyone give me a suggestion, please?
Also, if you think there are more suitable ways to present that type of data, do not hesitate to give me better suggestions.
I am wondering if there are too many categories on this graph...
Here a -dataex- sample:
Thank you in advance.
Best,
Michael
I would like to obtain a stack bar graph, but with frequencies on the y-axis that sum to 100% for each province, in order to have a better view of the different provinces.
I have produced a plot, but the y-axis does not show frequencies. Instead, it is the mean that is plotted.
Code:
groups sp_zipcode_twodigits, order(h) select(5) tempvar region_biggest region_order gen `region_biggest' = . replace `region_biggest' = 1 if sp_zipcode_twodigits == 43 // TARRAGONA replace `region_biggest' = 2 if sp_zipcode_twodigits == 46 // VALENCIA replace `region_biggest' = 3 if sp_zipcode_twodigits == 17 //GIRONA replace `region_biggest' = 4 if sp_zipcode_twodigits == 28 //MADRID replace `region_biggest' = 5 if sp_zipcode_twodigits == 8 //BARCELONA label define `region_order' 1 "Tarragona" 2 "València" 3 "Girona" 4 "Madrid" 5 "Barcelona" label values `region_biggest' `region_order' * Plotting forvalues i = 1/4 { local barlwidth "`barlwidth' bar(`i', lwidth(0)) " } graph bar kW_power_p1 if tariff_2 & tariff_2_more_15000_w == 0, over(tariff_ekon_id_encod) over(`region_biggest', label(labsize(2))) asyvars stack /// scheme(white_w3d) /// ylabel(, nogrid format(%9.0fc)) /// lintensity(*0) /// `barlwidth' /// title("{bf}Histogram on Tariffs", pos(11) size(2.75)) /// subtitle("Provinces across Tariff Types", pos(11) size(2))
Could anyone give me a suggestion, please?
Also, if you think there are more suitable ways to present that type of data, do not hesitate to give me better suggestions.
I am wondering if there are too many categories on this graph...
Here a -dataex- sample:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(kW_power_p1 tariff_2 tariff_2_more_15000_w obs_by_zipcode_house) 2.3 1 0 6663 3.3 1 0 6663 3.45 1 0 6663 2.3 1 0 6663 2.3 1 0 6663 3.3 1 0 6663 3.45 1 0 6663 3 1 0 6663 3.45 1 0 6663 3.3 1 0 6663 2.3 1 0 6663 2 1 0 6663 3.45 1 0 6663 2.3 1 0 6663 3.4 1 0 6663 3.45 1 0 6663 2.3 1 0 6663 1 1 0 6663 3.45 1 0 6663 3.3 1 0 6663 2.3 1 0 6663 3.3 1 0 6663 3.45 1 0 6663 3.45 1 0 6663 3.1 1 0 6663 5.5 1 0 6663 2.3 1 0 6663 2.3 1 0 6663 4 1 0 6663 3.5 1 0 6663 4.6 1 0 6663 2.2 1 0 6663 3.45 1 0 6663 5.5 1 0 6663 3.3 1 0 6663 3.45 1 0 6663 2.3 1 0 6663 3.4 1 0 6663 3.1 1 0 6663 2.2 1 0 6663 2.3 1 0 6663 3.45 1 0 6663 4 1 0 6663 3.45 1 0 6663 2.8 1 0 6663 3.3 1 0 6663 3.4 1 0 6663 3.45 1 0 6663 3.45 1 0 6663 3.3 1 0 6663 3.45 1 0 6663 3.1 1 0 6663 4 1 0 6663 1.15 1 0 6663 3.45 1 0 6663 5.4 1 0 6663 2.3 1 0 6663 3.3 1 0 6663 2.3 1 0 6663 2.3 1 0 6663 5.4 1 0 6663 2 1 0 6663 4 1 0 6663 3.45 1 0 6663 2.3 1 0 6663 3.45 1 0 6663 3.45 1 0 6663 3.3 1 0 6663 3.3 1 0 6663 3.45 1 0 6663 3.3 1 0 6663 2.3 1 0 6663 3.45 1 0 6663 3.3 1 0 6663 2.3 1 0 6663 4.6 1 0 6663 2.3 1 0 6663 2.3 1 0 6663 3.3 1 0 6663 3.45 1 0 6663 1.725 1 0 6663 2.3 1 0 6663 3.45 1 0 6663 6.2 1 0 6663 4 1 0 6663 4.6 1 0 6663 4 1 0 6663 3.45 1 0 6663 13.2 1 0 6663 3.45 1 0 6663 3.1 1 0 6663 3.45 1 0 6663 3.45 1 0 6663 3.45 1 0 6663 3.45 1 0 6663 3.1 1 0 6663 3.45 1 0 6663 2.3 1 0 6663 3.5 1 0 6663 2.3 1 0 6663 end
Thank you in advance.
Best,
Michael