移动轴标签ggplot [英] move axis labels ggplot

查看:166
本文介绍了移动轴标签ggplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ggplot2中创建了一个事实图,x轴标签(底部)略微触及了比例值(当我绘制为.pdf设备时,它会变差)。

I have produced a fact graph in ggplot2 and the x axis label (bottom) is touching the scale values slightly (it's worsened when I plot to .pdf device). How do I move the axis label down a smidge?

DF<-structure(list(race = structure(c(3L, 1L, 3L, 2L, 3L, 1L, 2L, 
2L, 2L, 3L, 2L, 1L, 3L, 3L, 3L, 3L, 2L, 1L, 2L, 3L), .Label = c("asian", 
"black", "white"), class = "factor"), gender = structure(c(1L, 
1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, 
2L, 2L, 2L), .Label = c("female", "male"), class = "factor"), 
    score = c(0.0360497844302483, 0.149771418578119, 0.703017688328021, 
    1.32540102136392, 0.627084455719946, -0.320051801571444, 
    0.852281028633536, -0.440056896755573, 0.621765489966213, 
    0.58981396944136, 1.95257757882381, 0.127301498272644, -0.0906338578670778, 
    -0.637727808028146, -0.449607617033673, 1.03162398117388, 
    0.334259623567608, 0.0912327543652576, -0.0789977852804991, 
    0.511696466039959), time1 = c(75.9849658266583, 38.7148843859919, 
    54.3512613852158, 37.3210772390582, 83.8061071736856, 14.3853324033061, 
    79.2285735003004, 31.1324602891428, 22.2294730114138, 26.427263191766, 
    40.5529893144888, 19.2463281412667, 8.45085646487301, 97.6770352620696, 
    61.1874163107771, 31.3727683430548, 99.4155144857594, 79.0996849438957, 
    21.2504885323517, 94.1079332400361)), .Names = c("race", 
"gender", "score", "time1"), class = "data.frame", row.names = c(NA, 
-20L))


require(ggplot2)
p <- ggplot(DF, aes(score, time1, group=gender))
p + geom_point(aes(shape=19)) + facet_grid(race~gender) + scale_x_continuous('BLAH BLAH') + 
scale_y_continuous('Some MOre Of theat Good Blahing') 

在我的数据BLAH BLAH正在触摸这些数字。我需要它下移。如何?

In my data BLAH BLAH is touching the numbers. I need it to move down. How?

推荐答案

您可以使用以下方法调整x轴标题的位置:

You can adjust the positioning of the x-axis title using:

+ opts(axis.title.x = theme_text(vjust=-0.5))

使用-0.5垂直对齐参数进行游戏,直到它适合您/您的显示设备。

Play around with the -0.5 "vertical justification" parameter until it suits you/your display device.

这篇关于移动轴标签ggplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆