Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labels getting corrupted #17

Open
paulocr opened this issue Nov 4, 2019 · 1 comment
Open

Labels getting corrupted #17

paulocr opened this issue Nov 4, 2019 · 1 comment

Comments

@paulocr
Copy link

paulocr commented Nov 4, 2019

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")
@kwstat
Copy link
Owner

kwstat commented Nov 7, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants