I have an correlation matrix object I created with 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)
I'm trying to save it as a pdf. For some reason I can't figure out how to do that. Any help appreciated. Thank you!
Start the pdf graphics driver then call your plot.
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()
Although it is an old question, I thought of providing an alternate approach using recordPlot()
, replayPlot()
and 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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With