0

我正在绘制一个跨级别的交互,但是图例独立地显示了所有分数,而不是像我们通常在热图中找到的那样以彩色刻度显示。如何从我的聚类变量“w”中获取信息以显示在更简洁的图例中(即,只有一个具有全范围颜色的条形和几个分数标记)?

这是我的代码,图表当前的样子

提前致谢!

graph2 <- ggplot(data = data1a,
       aes(x = x2, 
           y = y, 
           col = as.factor(w)))+
  viridis::scale_color_viridis(discrete = TRUE)+
  geom_point(size     = .7,
             alpha    = .8, 
             position = "jitter")+
  geom_smooth(method = lm,
              se     = FALSE,
              size   = .5,
              alpha  = .8)+
  theme_minimal()+
  labs(title    = "Linear Relationship for Different wards as Observed", 
       subtitle = "", 
       col      = "Years of\nTeacher\nExperience")

graph2

GGplot2中的交互图

4

1 回答 1

0

将您的替换viridis::scale_color_viridis(discrete = TRUE)scale_color_gradient(low = "blue", high = "green").

于 2020-07-11T12:03:29.457 回答