r - change distance of x-axis labels from axis in sciplot bargraph -


i'm constructing plot using bargraph.ci sciplot. x-axis represents categorical variable, values of variable names different positions on x-axis. unfortunately these names long, @ default settings, of them disappear. solved problem splitting them multiple lines injecting "\n" needed. worked, because names multi-line, close x-axis. need move them farther away. how?

i know can mgp, affects y-axis too.

i know can set axisnames=false in call barplot.ci, use axis create separate x-axis. (in fact, i'm doing that, make x-axis extend farther default- see code below.) give x-axis own mgp parameter not affect y-axis. far can tell, axis() set ordinal or continuous variables , doesn't seem work great categorical variables. after fiddling, couldn't put names in right locations (i.e. right under correspondence bars)

finally, tried using mgp.axis.labels hmisc set x-axis mgp, precisely want, far tell had no effect on anything.

ideas? here's code.

ylim    = c(0.5,0.8) yticks  = seq(ylim[1],ylim[2],0.1) ylab    = paste(100*yticks,"%",sep="")  bargraph.ci(      response    = d$accuracy,     ylab        = "% accuracy on test",     ylim        = ylim,     x.factor    = d$training,     xlab        = "training condition",     axes        = false     ) axis(     side        = 1,     pos         = ylim[1],     @          = c(0,7),     tick        = true,     labels      = false     ) axis(     side        = 2,     tick        = true,     @          = yticks,     labels      = ylab,     las         = 1     ) 

axis works fine cateory should set right ticks values , play pos parameter offset translation. here use xvals return value of bargraph.ci set àxis tick marks.

here reproducible example:

enter image description here

library(sciplot) # using sciplot data  dat <- toothgrowth ### create along labels labels <- c('aaaaaaaaaa\naaaaaaaaaaa\nhhhhhhhhhhhhhhh',           'bbbbbbbbbb\nbbbbbbbbbbb\nhhhhhhhhhhhhhh',           'cccccccccc\nccccccccccc\ngdgdgdgdgd') ## change factor labels dat$dose <- factor(dat$dose,labels=labels) ll <- bargraph.ci(x.factor = dose, response = len, data = dat,axisnames=false)  ## set @ xvals axis(side=1,at=ll$xvals,labels=labels,pos=-2,tick=false) 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -