Mikata-Project / ggthemr

Themes for ggplot2.
882 stars 107 forks source link

Missing theme elements in ggplot2 3.1 #31

Open RPDcoetic opened 5 years ago

RPDcoetic commented 5 years ago

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!

tungttnguyen commented 5 years ago

Probably related to this recent commit from ggplot2

paleolimbot commented 5 years ago

@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 commented 5 years ago

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

krlmlr commented 5 years ago

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