我有一个用 corrplot 创建的相关矩阵对象
p1 <- corrplot(correlations_history, method = "number", type = "lower", title = "Regional Factor Correlation Matrix over history", mar = c(0,0,1,0), number.cex = 0.5, number.digits = 2)
Run Code Online (Sandbox Code Playgroud)
我正在尝试将其另存为 pdf。出于某种原因,我无法弄清楚如何做到这一点。任何帮助表示赞赏。谢谢!
小智 11
虽然这是一个老问题,但我想提供一种使用 recordPlot(),replayPlot()和的替代方法ggsave()。
p1 <- { # Prepare the Corrplot
corrplot(correlations_history,
method = "number",
type = "lower",
title = "Regional Factor Correlation Matrix over history",
mar = c(0,0,1,0),
number.cex = 0.5,
number.digits = 2);
# Call the recordPlot() function to record the plot
recordPlot()
}
# In case if you want to save the image using ggsave
# replayPlot basically prints the plot.
library(ggplot2)
ggsave(filename = "p1.pdf", plot = replayPlot(p1))
Run Code Online (Sandbox Code Playgroud)
启动 pdf 图形驱动程序,然后调用您的绘图。
pdf(file = "yourfilename.pdf")
corrplot(correlations_history, method = "number", type = "lower",
title = "Regional Factor Correlation Matrix over history",
mar = c(0,0,1,0), number.cex = 0.5, number.digits = 2)
dev.off()
Run Code Online (Sandbox Code Playgroud)