Skip to content

Fix vertical justification for rotated text #883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed

Fix vertical justification for rotated text #883

wants to merge 7 commits into from

Conversation

krlmlr
Copy link
Member

@krlmlr krlmlr commented Dec 10, 2013

The computation for x (or y) values based on vjust values does not work correctly for all cases. I have shown an example before and after applying this change.

Before

Everything looks good by default

library(ggplot2)
## Loading required package: methods
library(grid)

(p <- qplot(diamonds$cut, binwidth=0.5) + theme_bw(24) +
   theme(axis.text.x=element_text(vjust=0.5)))
showViewport()

plot of chunk unnamed-chunk-2

Now play with the justification:

(p0 <- p + theme(axis.title=element_text(vjust=0)))
showViewport()

plot of chunk unnamed-chunk-3

And the other extreme:

(p1 <- p + theme(axis.title=element_text(vjust=1)))
showViewport()

plot of chunk unnamed-chunk-4

Top-down:

p0 + theme(axis.title.x=element_text(angle=180), axis.title.y=element_text(angle=270))
showViewport()

plot of chunk unnamed-chunk-5

Top-down, vjust==1:

p1 + theme(axis.title.x=element_text(angle=180), axis.title.y=element_text(angle=270))
showViewport()

plot of chunk unnamed-chunk-6

This is inconsistent.

After

Everything looks good by default

library(ggplot2)
## Loading required package: methods
library(grid)

(p <- qplot(diamonds$cut, binwidth=0.5) + theme_bw(24) +
   theme(axis.text.x=element_text(vjust=0.5)))
showViewport()

plot of chunk unnamed-chunk-2

Now play with the justification:

(p0 <- p + theme(axis.title=element_text(vjust=0)))
showViewport()

plot of chunk unnamed-chunk-3

And the other extreme:

(p1 <- p + theme(axis.title=element_text(vjust=1)))
showViewport()

plot of chunk unnamed-chunk-4

Top-down:

p0 + theme(axis.title.x=element_text(angle=180), axis.title.y=element_text(angle=270))
showViewport()

plot of chunk unnamed-chunk-5

Top-down, vjust==1:

p1 + theme(axis.title.x=element_text(angle=180), axis.title.y=element_text(angle=270))
showViewport()

plot of chunk unnamed-chunk-6

Source

#-echo=F
library(knitr)
opts_chunk$set(fig.height=4)
opts_knit$set(upload.fun = imgur_upload)

#' Everything looks good by default
library(ggplot2)
library(grid)

(p <- qplot(diamonds$cut, binwidth=0.5) + theme_bw(24) +
   theme(axis.text.x=element_text(vjust=0.5)))
showViewport()

#' Now play with the justification:
(p0 <- p + theme(axis.title=element_text(vjust=0)))
showViewport()

#' And the other extreme:
(p1 <- p + theme(axis.title=element_text(vjust=1)))
showViewport()

#' Top-down:
p0 + theme(axis.title.x=element_text(angle=180), axis.title.y=element_text(angle=270))
showViewport()

#' Top-down, `vjust==1`:
p1 + theme(axis.title.x=element_text(angle=180), axis.title.y=element_text(angle=270))
showViewport()

#' This is inconsistent.

@hadley
Copy link
Member

hadley commented Feb 24, 2014

Could you please rebase/merge against master, re-document with the development version of roxygen2 (install_github("klutometis/roxygen) and resubmit?

@hadley hadley closed this Feb 24, 2014
@krlmlr
Copy link
Member Author

krlmlr commented Feb 25, 2014

Force-pushed to the same. Could you please re-open and merge this pull request?

@hadley hadley reopened this Feb 25, 2014
@hadley
Copy link
Member

hadley commented Feb 25, 2014

Actually could you please resubmit the PR? Then travis will get run.

@lock
Copy link

lock bot commented Jan 19, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants