ggplot 2 version 3.5.0 update guides; guide="prism_bracket" doesn't work. How to solve?

56 Views Asked by At

With the recent update of gglot2 for guide using the ggproto system. The following command doesn't work anymore.

scale_x_discrete(guide = "prism_bracket")

The issue is probably simple to solve, but I can't get it to work with the ggproto system. How can I update this command from the S3 guide system to ggproto? Thoughts?

A solution to be able update my current script for the updated ggplot2 (using ggproto for guide), so I can continue to use brackets for my discrete x-axis.

1

There are 1 best solutions below

0
Ben Bolker On

There's an existing pull request that solves this problem. It hasn't been integrated into the main branch of the development version, let alone being posted to CRAN, but you can install it with remotes::install_github():

remotes::install_github("csdaw/ggprism#25")
library(ggplot2)
library(ggprism)
base <- ggplot(mpg, aes(x = as.factor(cyl), y = hwy)) +
  geom_jitter(width = 0.2) +
  theme(axis.line = element_line(colour = "black"))
base + scale_x_discrete(guide = "prism_bracket")
packageVersion("ggplot2") ## 3.5.0