Hi Dan, Chances are that you haven't yet upgraded to ggplot2 version 2.0. unit (as well as arrow and alpha) are now re-exported from ggplot2. Using the latest release I also see that vjust doesn't seem to do anything. Best, Ista On Tue, Dec 22, 2015 at 1:37 PM, Nordlund, Dan (DSHS/RDA) <NordlDJ at dshs.wa.gov> wrote:> Are you sure it is not working for you? Your example code did not work for me at all until I removed the plot .margin parameter (unit wasn't recognized). Once I did that hjust and vjust worked as expected. However, values between .1 and .9 for vjust don't really move the axis title very much so it may not be real noticeable. Try a value like 2 or 3, just to make sure you easily see the change in position before concluding that nothing is happening. > > Dan > > Daniel Nordlund, PhD > Research and Data Analysis Division > Services & Enterprise Support Administration > Washington State Department of Social and Health Services > > > -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ryan Utz > Sent: Tuesday, December 22, 2015 10:00 AM > To: r-help at r-project.org > Subject: [R] vjust unresponsive (ggplot2) > > Hi all, > > I cannot for the life of me get my axis titles to adjust vertically in a ggplot. I've seen several posts about this and have tried everything: > keeping vjust within 0 and 1, adjusting the margins, etc. hjust is behaving just as it should but vjust just mocks me in silence. No error message is produced. > > Here's a sample code: > > x=data.frame(sample(1:10)) > x[,2]=sample(1:10) > > ggplot(data=x,aes(x=V2,y=V2))+theme(axis.title.y=element_text(vjust=.1,hjust=0.6), > plot.margin=unit(c(1,1,2,2),'cm')) > > No matter what I put into vjust, nothing happens. Am I missing something obvious?? > > Thanks ahead of time for any help, > Ryan > > > -- > > Ryan Utz, Ph.D. > Assistant professor of water resources > *chatham**UNIVERSITY* > Home/Cell: (724) 272-7769 > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Ista, You are correct, I was not at the latest release of ggplot2. I updated to the latest version and am now seeing the same result as you and the OP. So it does look like an issue with the latest version of ggplot2. Dan Daniel Nordlund, PhD Research and Data Analysis Division Services & Enterprise Support Administration Washington State Department of Social and Health Services> -----Original Message----- > From: Ista Zahn [mailto:istazahn at gmail.com] > Sent: Tuesday, December 22, 2015 10:48 AM > To: Nordlund, Dan (DSHS/RDA) > Cc: r-help at r-project.org > Subject: Re: [R] vjust unresponsive (ggplot2) > > Hi Dan, > > Chances are that you haven't yet upgraded to ggplot2 version 2.0. unit (as > well as arrow and alpha) are now re-exported from ggplot2. > > Using the latest release I also see that vjust doesn't seem to do anything. > > Best, > Ista > > On Tue, Dec 22, 2015 at 1:37 PM, Nordlund, Dan (DSHS/RDA) > <NordlDJ at dshs.wa.gov> wrote: > > Are you sure it is not working for you? Your example code did not work for > me at all until I removed the plot .margin parameter (unit wasn't > recognized). Once I did that hjust and vjust worked as expected. However, > values between .1 and .9 for vjust don't really move the axis title very much > so it may not be real noticeable. Try a value like 2 or 3, just to make sure you > easily see the change in position before concluding that nothing is > happening. > > > > Dan > > > > Daniel Nordlund, PhD > > Research and Data Analysis Division > > Services & Enterprise Support Administration Washington State > > Department of Social and Health Services > > > > > > -----Original Message----- > > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ryan > > Utz > > Sent: Tuesday, December 22, 2015 10:00 AM > > To: r-help at r-project.org > > Subject: [R] vjust unresponsive (ggplot2) > > > > Hi all, > > > > I cannot for the life of me get my axis titles to adjust vertically in a ggplot. > I've seen several posts about this and have tried everything: > > keeping vjust within 0 and 1, adjusting the margins, etc. hjust is behaving > just as it should but vjust just mocks me in silence. No error message is > produced. > > > > Here's a sample code: > > > > x=data.frame(sample(1:10)) > > x[,2]=sample(1:10) > > > > ggplot(data=x,aes(x=V2,y=V2))+theme(axis.title.y=element_text(vjust=.1 > > ,hjust=0.6), > > plot.margin=unit(c(1,1,2,2),'cm')) > > > > No matter what I put into vjust, nothing happens. Am I missing something > obvious?? > > > > Thanks ahead of time for any help, > > Ryan > > > > > > -- > > > > Ryan Utz, Ph.D. > > Assistant professor of water resources > > *chatham**UNIVERSITY* > > Home/Cell: (724) 272-7769 > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code.
vjust was always a hack that I never thought should work. The margins parameter is the correct way to solve this problem as of ggplot2 2.0.0. Hadley On Tuesday, December 22, 2015, Nordlund, Dan (DSHS/RDA) <NordlDJ at dshs.wa.gov> wrote:> Ista, > > You are correct, I was not at the latest release of ggplot2. I updated to > the latest version and am now seeing the same result as you and the OP. So > it does look like an issue with the latest version of ggplot2. > > Dan > > Daniel Nordlund, PhD > Research and Data Analysis Division > Services & Enterprise Support Administration > Washington State Department of Social and Health Services > > > > -----Original Message----- > > From: Ista Zahn [mailto:istazahn at gmail.com <javascript:;>] > > Sent: Tuesday, December 22, 2015 10:48 AM > > To: Nordlund, Dan (DSHS/RDA) > > Cc: r-help at r-project.org <javascript:;> > > Subject: Re: [R] vjust unresponsive (ggplot2) > > > > Hi Dan, > > > > Chances are that you haven't yet upgraded to ggplot2 version 2.0. unit > (as > > well as arrow and alpha) are now re-exported from ggplot2. > > > > Using the latest release I also see that vjust doesn't seem to do > anything. > > > > Best, > > Ista > > > > On Tue, Dec 22, 2015 at 1:37 PM, Nordlund, Dan (DSHS/RDA) > > <NordlDJ at dshs.wa.gov <javascript:;>> wrote: > > > Are you sure it is not working for you? Your example code did not > work for > > me at all until I removed the plot .margin parameter (unit wasn't > > recognized). Once I did that hjust and vjust worked as expected. > However, > > values between .1 and .9 for vjust don't really move the axis title very > much > > so it may not be real noticeable. Try a value like 2 or 3, just to make > sure you > > easily see the change in position before concluding that nothing is > > happening. > > > > > > Dan > > > > > > Daniel Nordlund, PhD > > > Research and Data Analysis Division > > > Services & Enterprise Support Administration Washington State > > > Department of Social and Health Services > > > > > > > > > -----Original Message----- > > > From: R-help [mailto:r-help-bounces at r-project.org <javascript:;>] On > Behalf Of Ryan > > > Utz > > > Sent: Tuesday, December 22, 2015 10:00 AM > > > To: r-help at r-project.org <javascript:;> > > > Subject: [R] vjust unresponsive (ggplot2) > > > > > > Hi all, > > > > > > I cannot for the life of me get my axis titles to adjust vertically in > a ggplot. > > I've seen several posts about this and have tried everything: > > > keeping vjust within 0 and 1, adjusting the margins, etc. hjust is > behaving > > just as it should but vjust just mocks me in silence. No error message is > > produced. > > > > > > Here's a sample code: > > > > > > x=data.frame(sample(1:10)) > > > x[,2]=sample(1:10) > > > > > > ggplot(data=x,aes(x=V2,y=V2))+theme(axis.title.y=element_text(vjust=.1 > > > ,hjust=0.6), > > > plot.margin=unit(c(1,1,2,2),'cm')) > > > > > > No matter what I put into vjust, nothing happens. Am I missing > something > > obvious?? > > > > > > Thanks ahead of time for any help, > > > Ryan > > > > > > > > > -- > > > > > > Ryan Utz, Ph.D. > > > Assistant professor of water resources > > > *chatham**UNIVERSITY* > > > Home/Cell: (724) 272-7769 > > > > > > [[alternative HTML version deleted]] > > > > > > ______________________________________________ > > > R-help at r-project.org <javascript:;> mailing list -- To UNSUBSCRIBE > and more, see > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > > > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > ______________________________________________ > > > R-help at r-project.org <javascript:;> mailing list -- To UNSUBSCRIBE > and more, see > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > > > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ > R-help at r-project.org <javascript:;> mailing list -- To UNSUBSCRIBE and > more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- http://had.co.nz/ [[alternative HTML version deleted]]