简体   繁体   English

我无法从 R 正确保存图

[英]I cannot save correctly plots from R

I created a boxplot on r using boxplot .我使用 boxplot 在 r 上创建了一个箱boxplot

boxplot_nonorm= boxplot(log10(table_tissues_filtered_high+1), 
                        las=2, 
                        main= "Data not normalized",
                        col= "light green", )

Then I saved it as image and as pdf but the files generated are truncated.然后我将它保存为图像和 pdf 但生成的文件被截断。 I report an example我报告一个例子在此处输入图像描述

I cannot read the label names.我无法读取 label 名称。 How can I fix it?我该如何解决?

you need to increase the margin before you save your plot.在保存 plot 之前,您需要增加边距。 You can change the margin with the mar in the par() c(bottom, left, top, right)您可以使用par() c(bottom, left, top, right)中的mar更改边距

png(filename="figure.png", width=900, bg="white")
par(mar=c(10,6,4,1))
boxplot(mtcars, names = c(paste0("very_long_label",1:11)), las = 2)
dev.off()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM