[英]Graph legend in R shows too much data
I'm plotting a cross-level interaction, but the legend shows all of the scores, independently , instead of in a ranged colored scale, as the ones we usually find in heatmaps.我正在绘制一个跨级别的交互,但是图例独立地显示了所有分数,而不是像我们通常在热图中找到的那样以彩色刻度显示。 How can I get the information from my clustering variable 'w' to show in a more parsimonious legend (ie, only one bar with the full range of colors, and a couple of score-markers)?
如何从我的聚类变量“w”中获取信息以显示在更简洁的图例中(即,只有一个条形图具有全范围的 colors 和几个分数标记)?
This is my code, and what the graph currently looks like这是我的代码,图表当前的样子
Thanks in advance!提前致谢!
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
Replace your viridis::scale_color_viridis(discrete = TRUE)
with scale_color_gradient(low = "blue", high = "green")
.将您的
viridis::scale_color_viridis(discrete = TRUE)
替换为scale_color_gradient(low = "blue", high = "green")
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.