geom_half_point (ggbeeswarm) position_jitter width inconsistent output

Viewed 24

I am using a combination of ggplot2, gghalves (for box plot) and ggbeeswarm (for half points) to create half a boxplot and half a scatter plot for my data.

This is the code I'm using:

Br_bs <- ggplot(data = bridgeport_bs, aes(x=Distance, y=Quantity, group=Site)) +
  geom_half_boxplot(fill="white", outlier.colour = NA, width = 1.1) +
  geom_half_point(position=position_jitter(width=1, height=0), side = "r", 
                  size=3, color = "black", fill = "darkgoldenrod", 
                  shape = 24, aes(x=Distance, y=Quantity)) +
  scale_y_continuous(limits = c(-1, 6), breaks = c(0, 2, 4, 6)) +
  scale_x_continuous(limits = c(-1, 15), breaks = c(0, 5, 10, 15)) +
  labs(y="Quantity (pg/mL)", x="Downstream Distance (km)") +
  ggtitle("Lake Bridgeport")
Br_bs  + theme(plot.title = element_text(hjust = 0.5, size = 15, face = "bold"))

The output keeps changing in regards to where the jitters are positioned. It only happens when I mess with the width in geom_half_point. I would like the jitters to be directly on the right side of the half boxplot, but I can't seem to get it right.

This is my current output:

Box/scatter output

Another issue I keep having is even if I keep the code the exact same and try outputting it again, I get this error:

Error

And have to mess with the width again to even get a plot output where the jitters are all over the place.

0 Answers
Related