首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >将相关矩阵图形另存为PDF

将相关矩阵图形另存为PDF
EN

Stack Overflow用户
提问于 2018-06-01 03:40:21
回答 3查看 7.5K关注 0票数 4

我有一个使用corrplot创建的相关矩阵对象

代码语言:javascript
复制
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格式。由于某种原因,我想不出该怎么做。感谢您的帮助。谢谢!

EN

回答 3

Stack Overflow用户

发布于 2018-06-03 18:16:28

启动pdf图形驱动程序,然后调用您的绘图。

代码语言:javascript
复制
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()
票数 7
EN

Stack Overflow用户

发布于 2021-07-15 23:23:50

代码语言:javascript
复制
# 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()
票数 1
EN

Stack Overflow用户

发布于 2021-07-29 20:37:41

虽然这是一个古老的问题,但我想提供一种使用recordPlot()replayPlot()ggsave()的替代方法。

代码语言:javascript
复制
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))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50631646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档