gpt4 book ai didi

删除ggplot2中的边框

转载 作者:行者123 更新时间:2023-12-02 01:23:12 25 4
gpt4 key购买 nike

<分区>

我想使用 ggplot2 删除 .png 输出文件中的白色边框。我将 Windows 10 与 Rstudio、ggplot2geom_raster 一起使用。花时间在论坛上搜索并尝试了一些参数后,我得到了这段代码(仍然不起作用):

library(ggplot2)
library(datasets)

png(file = "Out.png")

par(mar=rep(0, 4), plt=c(0.1,0.9,0.1,0.9), xpd=NA)

ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density))+
theme(axis.line = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
panel.margin = unit(0,"null"),
legend.position = "none",
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.background = element_blank(),
plot.margin = rep(unit(0,"null"),4))

dev.off()

此代码给出此 png:

enter image description here

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com