【发布时间】:2018-11-21 18:43:20
【问题描述】:
我想从 R 中的 excel 复制一个图表。为此,我必须创建一个图表,其中图表的所有边框区域都被着色,如下所示:
我尝试了很多方法,也搜索了很多,但没有结果。
请帮忙。
谢谢
【问题讨论】:
-
“边境地区”是什么意思?您的问题不清楚。
我想从 R 中的 excel 复制一个图表。为此,我必须创建一个图表,其中图表的所有边框区域都被着色,如下所示:
我尝试了很多方法,也搜索了很多,但没有结果。
请帮忙。
谢谢
【问题讨论】:
听起来您想更改 ggplot 的主题。很多选项under the hood。这是执行您所描述的基本示例:
set.seed(42)
example <- data.frame(x = 1:100, value = rnorm(100))
library(ggplot2)
ggplot(example, aes(x, value)) +
geom_line() +
# here's where we set the appearance of the theme
# For more: https://ggplot2.tidyverse.org/reference/theme.html
theme(plot.background = element_rect(fill = "gray75"), # region outside plot
panel.background = element_rect(fill = "white"), # region inside plot
panel.grid = element_line(color = "gray90")) # bring back gridlines
【讨论】: