The spaces between two dots are vary, some are very far, and some are very narrow. And also, the order between two dots is likely random (Some are "non-transplan" are in the left, some are in the right). Meanwhile, my desire plot is the spaces between two dots and also the order of the group are same for all the data.
How do I fix this?
I use ggplot and geom_jitter:
ggplot(Play1, aes(x=Month, y=Species, size=Value, color=Status)) +
geom_jitter(width=0.1, height = 0)
I also tried with position_nudge & position_dodgebut I cannot use geom_point because geom_point make the dots are on top of each other.
jitter(position = position_dodge(width=0.5))
As there seems to be only one observation by Month
, Species
and Status
one option would be to use geom_point
with position_dodge()
and to explicitly map Status
on the group
aes so that points get dodged by Status
. This will put one status group on the left and the other on the right.
Using some fake random example data:
set.seed(123)
Play1 <- expand.grid(
Month = month.name[9:12],
Species = LETTERS,
Status = c("Nontransplan", "Transplan")
)
Play1$Value <- runif(nrow(Play1), 0, 250)
library(ggplot2)
ggplot(Play1, aes(
x = Month, y = Species,
size = Value, color = Status
)) +
geom_point(
aes(group = Status),
position = position_dodge(width = .5)
) +
# Just for the reprex
scale_size_area(limits = c(0, 250), max_size = 3)