Skip to content
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

Missing theme elements in ggplot2 3.1 #31

Open
RPDcoetic opened this issue Apr 17, 2019 · 4 comments
Open

Missing theme elements in ggplot2 3.1 #31

RPDcoetic opened this issue Apr 17, 2019 · 4 comments

Comments

@RPDcoetic
Copy link

ggplot2 just updated 6 days ago to 3.1.1. Loading a ggthemr theme now throws the following message:
Warning message:
New theme missing the following elements: axis.ticks.length.x, axis.ticks.length.x.top, axis.ticks.length.x.bottom, axis.ticks.length.y, axis.ticks.length.y.left, axis.ticks.length.y.right

Calling ggplot now results in the following error:
Error in axis.ticks.length.x.bottom %||% axis.ticks.length.x :
object 'axis.ticks.length.x.bottom' not found

Any chance these elements can be specified in the themes or is there a workaround? Thank you!

@sainathadapa sainathadapa self-assigned this Apr 22, 2019
@tungttnguyen
Copy link

Probably related to this recent commit from ggplot2

@paleolimbot
Copy link

@tungmilan - it looks like you've noted this already. The way that ggthemer defines its themes makes it difficult for us to improve themes without breaking code in your package. We recommend using code like the following to define new themes, so that we can continue to improve the ggplot2 theme system without breaking others' code:

theme_custom <- function(base_size = 11, base_family = "", 
                         base_line_size = base_size/22, base_rect_size = base_size/22) {
  # Starts with theme_grey and then modify some parts
  ggplot2::theme_grey(
    base_size = base_size,
    base_family = base_family,
    base_line_size = base_line_size,
    base_rect_size = base_rect_size
  ) %+replace%
    ggplot2::theme(
      # insert your custom theme elements here
    )
}

For this to work, you will have to import %+replace% into your package namespace, which you can do by adding the following line to any roxygen documentation block:

#' @importFrom ggplot2 %+replace%

Even if you seemingly override every element, inheriting from an existing ggplot2 theme will make it easier for us to add elements in the future. Let me know if I can help! We are hoping to release the next version of ggplot2 in the next two weeks.

@sainathadapa
Copy link
Collaborator

@paleolimbot Thanks, I'll take a look at this, sometime this week.

@krlmlr
Copy link

krlmlr commented May 14, 2019

Can replicate on Travis: https://travis-ci.org/krlmlr/ggthemr/jobs/532527507#L2305.

@sainathadapa sainathadapa removed their assignment Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants