Hello, does anyone know how to change the colour palette for heatplot so Stata uses shades of blue for negative correlations, shades of red for positive correlations, and 0 = white? I am now using
but it drives me crazy that 0 is not assigned to white, aka the cutoff between red and blue.
Thank you!
Code:
color(hcl blured)
Thank you!
Code:
en touse = !missing(SWLS, Sleepquality, Sleepduration, Sleephygiene, Bedtimeprocrastination, Age, Education, EmploymentStatus, Income, LivingSituation, Nightshift, Kids)
foreach v in SWLS Sleepquality Sleepduration Sleephygiene Bedtimeprocrastination Age Education EmploymentStatus Income LivingSituation Nightshift Kids {
egen rank_`v' = rank(`v') if touse
}
pwcorr rank_SWLS rank_Sleepquality rank_Sleepduration rank_Sleephygiene rank_Bedtimeprocrastination rank_Age rank_Education rank_EmploymentStatus rank_Income rank_LivingSituation rank_Nightshift rank_Kids, sig
matrix C = r(C)
matrix sig = r(sig)
heatplot C, values(label(sig)) lower nodraw nodiagonal generate
gen str lab = string(_Z, "%4.3f") + ///
cond(_Mlab<.001, "***", cond(_Mlab<.01, "**", cond(_Mlab<.05, "*", "")))
heatplot C, color(hcl bluered) lower aspectratio(1) xlabel(, labsize(tiny) angle(45)) ylabel(, labsize(tiny)) nodiagonal ///
addplot(scatter _Y _X, msymbol(i) mlab(lab) mlabpos(0) mlabcolor(black) mlabsize(tiny))

Comment