pairs(data, lower.panel = function(x, y) { points(x, y, pch = 19, cex = 0.5, col = "#3C9668") abline(lm(y ~ x), col = "red") }, diag.panel = function(x) { hist(x,col = "#D8EAF6",probability = TRUE,axes = FALSE,main = "",breaks = "FD") }, upper.panel = function(x, y) { corr_text <- round(cor(x, y), 2) symbol_size <- abs(corr_text) * 5 color_scale <- colorRampPalette(c("#F09576","white","#175A9E")) # 颜色比例尺 symbol_color <- color_scale(5 + corr_text * 5) #symbol_color <- ifelse(corr_text >= 0, "#F09576","#175A9E") symbols(1, 1, circles = symbol_size, inches = FALSE, bg = symbol_color) text(mean(x), mean(y), corr_text, cex = symbol_size*0.7, font = 1) }, labels = c("FBD", "VC", "EO","OF","DP","VC-FBD","EO-VC","OF-EO","DP-OF","DP-EO"), font.labels = list(cex = 1.5))又出现Error in plot.new() : figure margins too large的问题。怎么解决
时间: 2023-10-30 21:04:41 浏览: 130
这个错误通常是由于图形边距设置过大导致的。你可以尝试调整 `mar` 参数的值,来缩小图形边距。例如将 `mar` 设置为 `c(5, 4, 4, 2) + 0.1`,如果还是不行,可以进一步调整参数值。另外,你也可以将 `oma` 参数设置为较小的值,来进一步缩小图形的边距。例如:
```
pairs(data,
lower.panel = function(x, y) {
points(x, y, pch = 19, cex = 0.5, col = "#3C9668")
abline(lm(y ~ x), col = "red")
},
diag.panel = function(x) {
hist(x,col = "#D8EAF6",probability = TRUE,axes = FALSE,main = "",breaks = "FD")
},
upper.panel = function(x, y) {
corr_text <- round(cor(x, y), 2)
symbol_size <- abs(corr_text) * 5
color_scale <- colorRampPalette(c("#F09576","white","#175A9E")) # 颜色比例尺
symbol_color <- color_scale(5 + corr_text * 5) #symbol_color <- ifelse(corr_text >= 0, "#F09576","#175A9E")
symbols(1, 1, circles = symbol_size, inches = FALSE, bg = symbol_color)
text(mean(x), mean(y), corr_text, cex = symbol_size*0.7, font = 1)
},
labels = c("FBD", "VC", "EO","OF","DP","VC-FBD","EO-VC","OF-EO","DP-OF","DP-EO"),
font.labels = list(cex = 1.5),
mar = c(5, 4, 4, 2) + 0.1,
oma = c(0.5, 0.5, 0.5, 0.5)
)
```
你可以根据实际情况适当调整参数值。
阅读全文