I am trying to generate a heatplot with flags for significant correlations.
It looks great :-) using this code:
sysuse auto, clear
pwcorr price mpg trunk weight length turn foreign, sig
matrix C = r(C)
matrix sig = r(sig)
heatplot C, values (label(sig)) lower nodraw generate
// significance stars
gen str sig = cond(_Mlab<.05, "*", "")
heatplot C, legend(off) color(hcl diverging, intensity(.6)) lower aspectratio(1) ///
addplot(scatter _Y _X if _Y!=_X, msym(i) mlab(_Z) mlabf(%9.1f) mlabpos(0) mlabc(black) ///
|| scatter _Y _X if _Y==_X, msym(i) mlab(_Z) mlabf(%9.0f) mlabpos(0) mlabc(black) ///
|| scatter _Y _X if _Y!=_X, msym(i) mlab(sig) mlabpos(2) mlabgap(2) mlabc(black))

However, I have many more variables in my dataset, 39 variables. I can create a nice heatplot without the significance stars, by changing the size:
pwcorr var1, var2, var3, etc...
return list
matrix corrmatrix = r(C)
heatplot corrmatrix, values(format(%4.1f) size(1.1)) legend(off) color(hcl diverging, intensity(.7)) aspectratio(1) xlabel(,labsize(1.5) angle(90)) ylabel(,labsize(1.5)) lower nodiagonal

I would be grateful if someone can help me create a code including the significance marker and the smaller text. When adding the size option to the first, or second "heatplot C" it still does not give smaller size.
pwcorr var1, var2, var3, etc...
return list
matrix C = r(C)
matrix sig = r(sig)
heatplot C, values (label(sig)) lower nodraw generate
// significance stars
gen str sig = cond(_Mlab<.05, "*", "")
heatplot C, legend(off) color(hcl diverging, intensity(.6)) lower aspectratio(1) xlabel(,labsize(1.5) angle(90)) ylabel(,labsize(1.5)) ///
addplot(scatter _Y _X if _Y!=_X, msym(i) mlab(_Z) mlabf(%9.1f) mlabpos(0) mlabc(black) ///
|| scatter _Y _X if _Y==_X, msym(i) mlab(_Z) mlabf(%9.0f) mlabpos(0) mlabc(black) ///
|| scatter _Y _X if _Y!=_X, msym(i) mlab(sig) mlabpos(2) mlabgap(2) mlabc(black))
It looks great :-) using this code:
sysuse auto, clear
pwcorr price mpg trunk weight length turn foreign, sig
matrix C = r(C)
matrix sig = r(sig)
heatplot C, values (label(sig)) lower nodraw generate
// significance stars
gen str sig = cond(_Mlab<.05, "*", "")
heatplot C, legend(off) color(hcl diverging, intensity(.6)) lower aspectratio(1) ///
addplot(scatter _Y _X if _Y!=_X, msym(i) mlab(_Z) mlabf(%9.1f) mlabpos(0) mlabc(black) ///
|| scatter _Y _X if _Y==_X, msym(i) mlab(_Z) mlabf(%9.0f) mlabpos(0) mlabc(black) ///
|| scatter _Y _X if _Y!=_X, msym(i) mlab(sig) mlabpos(2) mlabgap(2) mlabc(black))
However, I have many more variables in my dataset, 39 variables. I can create a nice heatplot without the significance stars, by changing the size:
pwcorr var1, var2, var3, etc...
return list
matrix corrmatrix = r(C)
heatplot corrmatrix, values(format(%4.1f) size(1.1)) legend(off) color(hcl diverging, intensity(.7)) aspectratio(1) xlabel(,labsize(1.5) angle(90)) ylabel(,labsize(1.5)) lower nodiagonal
I would be grateful if someone can help me create a code including the significance marker and the smaller text. When adding the size option to the first, or second "heatplot C" it still does not give smaller size.
pwcorr var1, var2, var3, etc...
return list
matrix C = r(C)
matrix sig = r(sig)
heatplot C, values (label(sig)) lower nodraw generate
// significance stars
gen str sig = cond(_Mlab<.05, "*", "")
heatplot C, legend(off) color(hcl diverging, intensity(.6)) lower aspectratio(1) xlabel(,labsize(1.5) angle(90)) ylabel(,labsize(1.5)) ///
addplot(scatter _Y _X if _Y!=_X, msym(i) mlab(_Z) mlabf(%9.1f) mlabpos(0) mlabc(black) ///
|| scatter _Y _X if _Y==_X, msym(i) mlab(_Z) mlabf(%9.0f) mlabpos(0) mlabc(black) ///
|| scatter _Y _X if _Y!=_X, msym(i) mlab(sig) mlabpos(2) mlabgap(2) mlabc(black))
Comment