I create this plot in R:
I want to do 2 things:
- Add more factor levels to the x axis (intervals of 12hrs to match other data), I try with
scale_x_continuous(breaks = seq(0, 72, by = 12), labels = seq(0, 72, by = 12))
and other combinations but always return error. - add statistical values with bars instead of stars.
the code I try is here:
plot01 <- ggplot(df02_EC_01, aes(x=hrs, y=Vol_mm3, fill=Temp, color=Temp)) +
geom_dotplot(binaxis = "y",
stackdir = "centerwhole",
alpha = .5,
dotsize = .3,
method = "histodot",
binwidth = 1,
stackratio = 1,
position = "dodge",
binpositions="all") +
geom_boxplot(varwidth = T, size= .5, coef=500, alpha=.5) +
labs(title = "Decalcification Process with EDTA",
# subtitle = "EDTA",
# caption = "Data from p02-g01&02.R",
#tag = "Figure 1",
x = "Hours",
y = "Mineralized tissue (mm3)") +
theme(plot.title = element_text(hjust = 0.5)) +
stat_compare_means(aes(group=Temp), label = "p.signif") +
# scale_x_continuous(breaks = seq(0, 72, by = 12), labels = seq(0, 72, by = 12)) + # ERROR!!
ylim(0,30)
I include a dput of a sample of the data:
structure(list(ID = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10), Temp = c("RT", "RT", "RT", "RT",
"RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT",
"RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT",
"RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT",
"RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT", "RT",
"37C", "37C", "37C", "37C", "37C", "37C", "37C", "37C", "37C",
"37C", "37C", "37C", "37C", "37C", "37C", "37C", "37C", "37C",
"37C", "37C", "37C", "37C", "37C", "37C", "37C", "37C", "37C",
"37C", "37C", "37C", "37C", "37C", "37C", "37C"), Cond. = c("EC",
"EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC",
"EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC",
"EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC",
"EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC",
"EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC",
"EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC",
"EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC",
"EC", "EC", "EC", "EC"), hrs = structure(c(1L, 1L, 2L, 2L, 3L,
3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 1L, 1L, 2L, 2L, 3L,
3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 1L, 1L, 2L, 2L, 3L,
3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 1L, 1L, 2L, 2L, 3L,
3L, 4L, 4L, 5L, 5L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L,
6L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L), levels = c("0",
"12", "24", "48", "72", "96", "120", "144"), class = "factor"),
Side = c("L", "R", "L", "R", "L", "R", "L", "R", "L", "R",
"L", "R", "L", "R", "L", "R", "L", "R", "L", "R", "L", "R",
"L", "R", "L", "R", "L", "R", "L", "R", "L", "R", "L", "R",
"L", "R", "L", "R", "L", "R", "L", "R", "L", "R", "L", "R",
"L", "R", "L", "R", "L", "R", "L", "R", "L", "R", "L", "R",
"L", "R", "L", "R", "L", "R", "L", "R", "L", "R", "L", "R",
"L", "R", "L", "R", "L", "R", "L", "R", "L", "R", "L", "R"
), Vol_mm3 = c(26.64, 26.29, 20.33, 20.67, 15.17, 14.7, 5.62,
5.33, 3.72, 3.73, 3.93, 3.71, 4.34, 3.61, 2.22, 2.18, 21.27,
21.72, 14.92, 15, 7.17, 7.6, 3.29, 3.78, 2.36, 2.35, 2.95,
2.9, 0.88, 0.85, 0.72, 0.78, 25.25, 25.26, 17.56, 18.1, 10.19,
10.4, 5.89, 5.9, 4.92, 4.49, 1.03, 1, 2.26, 2.17, 1.83, 1.67,
24.4, 23.71, 6.59, 6.24, 4.24, 3.82, 2.28, 2.05, 1.03, 0.98,
22.93, 25.05, 6.75, 6.74, 4.21, 4.49, 2.33, 2.59, 1.06, 1.23,
0.07, 0.17, 24.04, 22.86, 7.1, 6.1, 4.01, 4.74, 2.99, 2.33,
1.24, 1.11, 0.13, 0.13)), class = c("grouped_df", "tbl_df",
"tbl", "data.frame"), row.names = c(NA, -82L), groups = structure(list(
hrs = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L,
6L, 6L, 7L, 8L), levels = c("0", "12", "24", "48", "72",
"96", "120", "144"), class = "factor"), Cond. = c("EC", "EC",
"EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC", "EC",
"EC", "EC"), Temp = c("37C", "RT", "37C", "RT", "37C", "RT",
"37C", "RT", "37C", "RT", "37C", "RT", "RT", "RT"), .rows = structure(list(
c(49L, 50L, 59L, 60L, 71L, 72L), c(1L, 2L, 17L, 18L,
33L, 34L), c(51L, 52L, 61L, 62L, 73L, 74L), c(3L, 4L,
19L, 20L, 35L, 36L), c(53L, 54L, 63L, 64L, 75L, 76L),
c(5L, 6L, 21L, 22L, 37L, 38L), c(55L, 56L, 65L, 66L,
77L, 78L), c(7L, 8L, 23L, 24L, 39L, 40L), c(57L, 58L,
67L, 68L, 79L, 80L), c(9L, 10L, 25L, 26L, 41L, 42L),
c(69L, 70L, 81L, 82L), c(11L, 12L, 27L, 28L, 43L, 44L
), c(13L, 14L, 29L, 30L, 45L, 46L), c(15L, 16L, 31L,
32L, 47L, 48L)), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -14L), .drop = TRUE))
Thank you for your support.