csdaw / ggprism

ggplot2 extension inspired by GraphPad Prism
https://csdaw.github.io/ggprism/
169 stars 20 forks source link

Guides aren't working in 1.0.5 and ggplot2 3.5.0 #33

Open araikes opened 4 weeks ago

araikes commented 4 weeks ago

Hi @csdaw,

I really like this package but have run into an issue. I have ggprism v 1.0.5 and ggplot2 v 3.5.1.

I get the following:

> ggplot(dorr_data, aes(x = sex, y = tbv, fill = sex)) +
+   stat_slab(side = "left", scale = 0.75, position = "dodge") +
+   stat_dotsinterval(scale = 0.5, position = "dodge", alpha = 0.5) +
+   stat_pointinterval(.width = .5,  # set to a scalar to draw only one label instead of two
+                      position = position_dodge(width = 1),
+                      size = 8
+   ) +
+   scale_fill_manual(values = c("#AB0520", "#0C234B")) +
+   facet_wrap( ~ allele_header) +
+   scale_y_continuous(limits = c(400, 525), expand = c(0,0),
+                      breaks = seq(400,525,25), guide = "prism_offset") +
+   labs(x = "",
+        y = expression(paste("Total brain volume (",mm^3,")", sep = ""))) +
+   theme(
+     plot.title = element_text(vjust = -0.5, size = 12),   # plot title size and position
+     axis.title.y = element_text(size = 15),
+     axis.text.y = element_text(size=12),        # y-axis text size
+     axis.text.x = element_text(size = 12),   # x-axis text size/face
+     strip.text = element_text(size = 15),
+     legend.position = "none")
Warning message:
The S3 guide system was deprecated in ggplot2 3.5.0.
ℹ It has been replaced by a ggproto system that can be extended.

The resultant plot has the right y-axis range but doesn't produce brackets:

image

Any thoughts on getting this work?

araikes commented 3 weeks ago

I figured it out. The vignette is out of date. Should be:


> ggplot(dorr_data, aes(x = sex, y = tbv, fill = sex)) +
+   stat_slab(side = "left", scale = 0.75, position = "dodge") +
+   stat_dotsinterval(scale = 0.5, position = "dodge", alpha = 0.5) +
+   stat_pointinterval(.width = .5,  # set to a scalar to draw only one label instead of two
+                      position = position_dodge(width = 1),
+                      size = 8
+   ) +
+   scale_fill_manual(values = c("#AB0520", "#0C234B")) +
+   facet_wrap( ~ allele_header) +
+   scale_y_continuous(limits = c(400, 525), expand = c(0,0),
+                      breaks = seq(400,525,25)) +
+   labs(x = "",
+        y = expression(paste("Total brain volume (",mm^3,")", sep = ""))) +
+   guides(y = "prism_offset") +
+   theme(
+     plot.title = element_text(vjust = -0.5, size = 12),   # plot title size and position
+     axis.title.y = element_text(size = 15),
+     axis.text.y = element_text(size=12),        # y-axis text size
+     axis.text.x = element_text(size = 12),   # x-axis text size/face
+     strip.text = element_text(size = 15),
+     legend.position = "none")