gpt4 book ai didi

R减小图表大小并从ggplot中删除灰色背景

转载 作者:行者123 更新时间:2023-12-04 12:19:53 25 4
gpt4 key购买 nike

我正在使用 ggplot 来绘制一些数据。它工作正常,但我想控制绘制区域的形状并删除灰色背景。

这是我现在使用的代码:

ggplot(data.melted, aes(x = Year, y = value, colour = variable)) +
geom_line() +
scale_x_continuous("Year") +
scale_y_continuous("Fraction of papers") +
scale_colour_discrete("Topics")

这是它产生的输出: enter image description here

最佳答案

ggplot(data.melted, aes(x = Year, y = value, colour = variable)) +
geom_line() +
scale_x_continuous("Year") +
scale_y_continuous("Fraction of papers") +
scale_colour_discrete("Topics") + theme(panel.background = element_blank())

保存绘图时指定尺寸。见 ?ggsave其他选项。
ggsave(p1, file = "plot.png", width = 5, height = 5)

关于R减小图表大小并从ggplot中删除灰色背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12654766/

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