The y-axis title appears too close to the axis text.
ggplot(mpg, aes(cty, hwy)) + geom_point()

I have tried changing the value of many parameters with theme() but none seems to help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From
ggplot2 2.0.0you can use themargin =argument ofelement_text()to change the distance between the axis title and the numbers. Set the values of themarginontop,right,bottom, andleft side of the element.margincan also be used for otherelement_textelements (see?theme), such asaxis.text.x,axis.text.yandtitle.addition
in order to set the margin for axis titles when the axis has a different position (e.g., with
scale_x_...(position = "top"), you’ll need a different theme setting – e.g.axis.title.x.top. See https://github.com/tidyverse/ggplot2/issues/4343.