1

我想出了一个使用ggplot的情节。我正在尝试使用 scale_shape_manual 手动更改我的点的形状,但它并没有真正起作用。

我正在使用的数据的标题:

 visit DF    UPDRS_type            score
  <int> <chr> <chr>                 <dbl>
1     1 A     UPDRSIIItotal_imputed  20.2
2     1 C     UPDRSIIItotal_imputed  26.7
3     1 D     UPDRSIIItotal_imputed  20.7
4     1 B     UPDRSIIItotal_imputed  22.9
5    12 A     UPDRSIIItotal_imputed  21.3
6    18 C     UPDRSIIItotal_imputed  29.2

并且:

unique(meanAcrossVisits$DF)
[1] "A" "C" "D" "B"
unique(meanAcrossVisits$UPDRS_type)
[1] "UPDRSIIItotal_imputed" "UPDRSIIIaxial_imputed" "UPDRSIIIlimb_imputed" `enter code here`

这是我正在使用的代码

ggplot(meanAcrossVisits, aes(x = visit, 
                            y = score, 
                            color = UPDRS_type,
                            shape = DF,
                            group = interaction(UPDRS_type, DF))) +
  
  geom_point(size = 4) +
  scale_shape_manual(values = c(16,17,15,18)) +
  geom_line(size = 1.1) +
  
  scale_x_discrete(name = "visit ( months )",
                   limits=c(1,12,18,24,36),
                   labels=c("BL","12","18","24","36"),
                   expand = c(0.03,0.03)) +
  guides(color = guide_legend(override.aes = list(size = 3))) +
  scale_shape_discrete(name = "Cohorts" ) +
  scale_colour_discrete(name = ("motor symptom")) +
  theme(axis.text=element_text(size=16),
        axis.title=element_text(size=14,face="bold"),
        plot.title = element_text(face = "bold", hjust = 0.5, size = 20)) +
  ggtitle("Change in the motor symptoms")

这给出了这个输出 在此处输入图像描述

有谁知道为什么 ggplot 无法识别以下值: scale_shape_manual(values = c(16,17,15,18))

4

0 回答 0