我有一个使用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)
我正试着把它保存为pdf格式。由于某种原因,我想不出该怎么做。感谢您的帮助。谢谢!
发布于 2018-06-03 18:16:28
启动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()
发布于 2021-07-15 23:23:50
# Initialize file path
file_path= "Correlation matrix.png"
png(height=1800, width=1800, file=file_path, type = "cairo")
# Your function to plot image goes here
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
)
# Then
dev.off()
发布于 2021-07-29 20:37:41
虽然这是一个古老的问题,但我想提供一种使用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))
https://stackoverflow.com/questions/50631646
复制相似问题