ggplot2 - Wrap column name text in ggpairs in R -


i using ggpairs , while plotting matrix, receive matrix follows

enter image description here

as can see, of text length large , hence text not seen completely. there anyway can wrap text visible completely.

code

ggpairs(df)  

i want text wrap can seen this

enter image description here

you can use labeller argument of ggpairs pass function applied facet strip text.

ggplot have nice ready function label_wrap_gen() wrap long labels.

by default ggpairs use column names labels, , can't contain spaces. label_wrap_gen() need spaces split labels on multiple rows.

this solution:

library(ggplot2) library(ggally) df <- iris  colnames(df) <- make.names(c('long colname',                    'quite long colname',                    'longer tha usual colname',                   'i\'m not sure should colname',                   'the ever longest colname 1 should allowed use'))  ggpairs(df,          columnlabels = gsub('.', ' ', colnames(df), fixed = t),          labeller = label_wrap_gen(10)) 


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -