Hi everyone,
I would like to know if there is a way to plot my kernel density graph, from biggest ZIP Codes values up to the lowest ones, please.
Here is my code:
And here a dataex:
You'll find enclosed the graph.
Thank you.
Best,
Michael
I would like to know if there is a way to plot my kernel density graph, from biggest ZIP Codes values up to the lowest ones, please.
Here is my code:
Code:
*First period (power_p1) density plot levelsof product_classification2, local(contract_type) foreach typeof of local contract_type { quietly summarize sp_zipcode_twodigits local kden "`kden' (kdensity sp_zipcode_twodigits if product_classification2 == `typeof', range(`r(min)' `r(max)') recast(area) fcolor(%60) lwidth(*0.25))" } twoway `kden', scheme(white_tableau) /// legend(subtitle("Contract Types:", size(2)) label(1 "Clasico") label(2 "Indexado") label(3 "Sin Sorpresas") label(4 "Tarifa Justa") rowgap(0.25) size(2)) /// title("{bf}Density Plot", pos(11) size(2.75)) /// ytitle("Density", size(2) orient(horizontal)) /// ylabel(, nogrid labsize(2)) /// xtitle("Spanish ZIP Codes (Two-Digits)", size(2)) /// xlabel(, nogrid labsize(2)) /// subtitle("Contract Types, by ZIP Code - First Period", pos(11) size(2)) graph export power_p1_graph_den.png, replace
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float id_numerical byte sp_zipcode_twodigits long(power_p1 power_p2 power_p3 product_classification2) 569333 1 2300 2300 . 1 921385 1 2300 2300 . 1 462401 1 12100 12100 . 1 741468 1 3450 3450 . 1 58547 1 4400 . . 1 203635 1 3450 3450 . 1 269687 1 2300 2300 . 1 338962 1 2800 2800 . 1 22992 1 3450 . . 1 1081254 1 4600 4600 . 1 73889 1 3450 3450 . 1 40220 1 3450 . . 1 752533 1 3000 3000 . 1 813338 1 3300 3300 . 1 1038631 1 3450 3450 . 1 161186 1 3450 3450 . 1 927645 1 4400 . . 1 764638 1 3300 3300 . 1 445455 1 4600 4600 . 1 488302 1 4600 . . 1 466732 1 2300 2300 . 1 714348 1 1000 1000 . 1 267934 1 2300 2300 . 1 267275 1 3300 3300 . 1 864177 1 3450 3450 . 1 3710 1 3450 . . 1 1206360 1 4400 4400 . 1 1127418 1 3450 3450 . 1 1058319 1 3450 3450 . 1 984224 1 2200 2200 . 1 598781 1 2300 2300 . 1 1104360 1 3900 3900 . 1 85052 1 4600 4600 . 1 819045 1 4400 4400 . 1 1140969 1 4600 4600 . 1 1275247 1 3450 3450 . 1 842802 1 3450 3450 . 1 139958 1 4600 4600 . 1 530660 1 3450 3450 . 1 189238 1 3500 3500 . 1 1126572 1 3450 3450 . 1 1178108 1 2000 2000 . 1 455702 1 9900 9900 . 1 1198344 1 3300 3300 . 1 558106 1 2300 . . 1 268569 1 3300 3300 . 1 45316 1 2300 2300 . 1 826981 1 3450 3450 . 1 527591 1 3300 3300 . 1 411715 1 2000 2000 . 1 end label values product_classification2 product_classification2 label def product_classification2 1 "Clasico", modify
Thank you.
Best,
Michael
Comment