vjust unresponsive (ggplot2)

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

vjust unresponsive (ggplot2)

utz.ryan
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: vjust unresponsive (ggplot2)

Ista Zahn
That looks to me like it might be buggy. At least I would have
expected vjust to do _something_.

In terms of the practical issue, you can adjust the distance between
the title and the axis with margin, e.g.

ggplot(data=x,aes(x=V2,y=V2))+theme(axis.title.y=element_text(margin =
margin(0, 5, 0, 0)))

Best,
Ista

On Tue, Dec 22, 2015 at 12:59 PM, Ryan Utz <[hidden email]> wrote:

> 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]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: vjust unresponsive (ggplot2)

Nordlund, Dan (DSHS/RDA)
In reply to this post by utz.ryan
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:[hidden email]] On Behalf Of Ryan Utz
Sent: Tuesday, December 22, 2015 10:00 AM
To: [hidden email]
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]]

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: vjust unresponsive (ggplot2)

Ista Zahn
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)
<[hidden email]> 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:[hidden email]] On Behalf Of Ryan Utz
> Sent: Tuesday, December 22, 2015 10:00 AM
> To: [hidden email]
> 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]]
>
> ______________________________________________
> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: vjust unresponsive (ggplot2)

Nordlund, Dan (DSHS/RDA)
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:[hidden email]]
> Sent: Tuesday, December 22, 2015 10:48 AM
> To: Nordlund, Dan (DSHS/RDA)
> Cc: [hidden email]
> 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)
> <[hidden email]> 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:[hidden email]] On Behalf Of Ryan
> > Utz
> > Sent: Tuesday, December 22, 2015 10:00 AM
> > To: [hidden email]
> > 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]]
> >
> > ______________________________________________
> > [hidden email] 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.
> >
> > ______________________________________________
> > [hidden email] 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.
______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: vjust unresponsive (ggplot2)

hadley wickham
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) <[hidden email]>
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:[hidden email] <javascript:;>]
> > Sent: Tuesday, December 22, 2015 10:48 AM
> > To: Nordlund, Dan (DSHS/RDA)
> > Cc: [hidden email] <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)
> > <[hidden email] <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:[hidden email] <javascript:;>] On
> Behalf Of Ryan
> > > Utz
> > > Sent: Tuesday, December 22, 2015 10:00 AM
> > > To: [hidden email] <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]]
> > >
> > > ______________________________________________
> > > [hidden email] <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.
> > >
> > > ______________________________________________
> > > [hidden email] <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.
> ______________________________________________
> [hidden email] <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]]

______________________________________________
[hidden email] 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.