corrgram icon indicating copy to clipboard operation
corrgram copied to clipboard

Labels getting corrupted

Open paulocr opened this issue 6 years ago • 1 comments

Hello,

I created a corrgram off some network captures. However, the text labels are getting cropped. I played around with the angles but it does not solve the issue. Any ideas on what is causing or how to correct? Screen Shot 2019-11-03 at 1 57 59 PM

Code utilized:

corrgram(df_stats, order=NULL, lower.panel=panel.shade, 
  upper.panel=NULL, text.panel=panel.txt,label.srt=5,
  main="PCAP variables Correlation")

paulocr avatar Nov 04 '19 20:11 paulocr

Here's an example that shows how to prevent text from being clipped:

# diagonal labels unclipped.
require(corrgram)
require('grid')
require('gridBase')
unclipped.txt <- function(x=0.1, y=0.5, txt, cex, font, srt){
  vps <- gridBase::baseViewports()
  vps$figure$clip <- NA # Hack. Do NOT clip text that falls outside the ploting region
  pushViewport(vps$inner) # Figure region
  pushViewport(vps$figure) # The diagonal box region
  grid.text(txt, x=0.1, y=y, just='left', gp=gpar(cex=cex))
  popViewport(2)
}
corrgram(mtcars[2:6], order=TRUE,
         labels=c("Cylinders","Displacement","Horsepower","Axle ratio","Weight"),
         cex.labels=2, adj=0,
         upper.panel=NULL, lower.panel=panel.conf,
         diag.panel=NULL, text.panel=unclipped.txt)

corrgram_unclipped

kwstat avatar Nov 07 '19 01:11 kwstat