[英]correlation plot in ggplot2 with different variables in x and y axis
我想使用 ggplot2 可视化这个相关矩阵。 是否有可能让它像 ggpairs() 一样但在 x 和 y 轴上有不同的变量?
round(cor(df_correlation),3)[c(1:5,58,61,66,67,70,71),72:77]
output:
Mastery_1 Mastery_2 Mastery_3 Mastery_4 Mastery_5 Mastery_6
Platform_joined 0.273 -0.049 0.160 0.238 0.324 0.161
gender 0.223 0.137 -0.076 0.235 0.097 -0.117
native_speaker -0.188 -0.511 -0.469 -0.263 -0.238 0.049
English_proficiency -0.094 -0.411 -0.388 -0.310 -0.221 0.104
SC0 0.453 0.442 0.391 0.497 0.453 0.261
end_Ask_qs -0.200 -0.338 -0.201 -0.226 -0.111 0.112
end_Review_notes 0.211 -0.183 0.153 0.307 0.412 0.430
end_Study_regularly 0.012 -0.182 0.014 0.123 0.188 0.232
end_Listen_carefully 0.060 -0.590 -0.298 -0.059 0.017 0.211
end_Class_attendance 0.018 -0.143 -0.042 -0.250 -0.233 -0.057
end_Discussion_participation 0.056 -0.119 0.247 -0.076 -0.046 0.382
谢谢你的任何提示!
您在这里只有相关值,这意味着您只能拥有写有相关性的ggpairs
面板类型 - 箱线图和散点图等其他类型需要完整的数据集。
从评论中,您似乎想要更多ggcorrplot
外观:
library(tidyverse)
df_correlation %>%
rownames_to_column() %>%
pivot_longer(-1) %>%
ggplot(aes(x = name, y = rowname, fill = value)) +
geom_tile() +
geom_text(aes(label = value)) +
coord_equal() +
scale_fill_gradient2(low = "blue3", mid = "white", high = "red3") +
labs(x = NULL, y = NULL)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.