0

ggpairs提供带有两个箱形图连接点的图表,以显示干预前后的情况。

  1. 想要更改 y 轴标签“Resist”“Suscept”而不是“3GCr”和“3GCs”。

  2. 并希望使用 r 默认形状更改数据点,例如 Resist= circle (1) & Suscept= Diamond(5)

搜索了几个网站,但没有得到想要的结果。还要添加代码和输出:

df.reach.sub <- data.frame(Resist = c(5.78, 3.85, 5.60, 7.83, 6.68, 7.90), Suscept =c(5.70, 3.70, 8.82, 8.67, 9.06, 8.08), Age = c(1,1,1,1,1,1), Status = c("Positive", "Positive", "Positive", "Positive", "Positive", "Positive"))

df.reach.subCat1 <- df.reach.sub[which(df.reach.sub$Age == "1-3" & df.reach.sub$Status == "Positive"),]
gp.plotCat1 <- ggpaired(df.reach.subCat1, cond1 = "Resist", cond2 = "Suscept", color = "Black", line.color = "gray", line.size = 0.4, palette = "npg", ylab = expression('log'[10]*' CFU / g faeces'), xlab = NULL, main = expression("A) 1-3 months ("*italic('p = 0.116, n = 6')*')'), legend = "none", ggtheme = theme_bw(), ylim = c(2,10))

gp.plotCat1

4

1 回答 1

0

我建议使用 sometidyverse和 "basic" ggplot2,像这样

df.reach.sub %>% 
  rownames_to_column() %>% 
  gather(key, value, -Age, -Status, -rowname) %>% 
  ggplot(aes(key, value)) +
    geom_boxplot() + 
    geom_point(aes(shape=key), show.legend = F, size=2) + 
    geom_path(aes(group=rowname)) + 
    theme_bw()

在此处输入图像描述

于 2018-11-05T09:23:11.560 回答