R 更改镶嵌面网格内单个绘图的线大小

R 更改镶嵌面网格内单个绘图的线大小,r,ggplot2,R,Ggplot2,我想更改单个facet\u网格中特定行的大小,并保持其他行不变。这是为了“突出”更多一行 伪造数据: set.seed(123) my_data <- data.frame( time = 1:100, a = runif(100, min = 0, max = 10), b = runif(100, min = 0, max = 20), c = runif(100, min = 0, max = 30) ) library(ggplot2) library(dply

我想更改单个
facet\u网格中特定行的大小,并保持其他行不变。这是为了“突出”更多一行

伪造数据:

set.seed(123)
my_data <- data.frame(
  time = 1:100,
  a = runif(100, min = 0, max = 10),
  b = runif(100, min = 0, max = 20),
  c = runif(100, min = 0, max = 30)
)


library(ggplot2)
library(dplyr)
my_data %>% 
  gather("key", "value", -time) %>%
  ggplot(aes(x = time, y = value, color = key)) +
  geom_line() +
  facet_grid(key~., scales = "free") +
  theme_minimal() +
  guides(color = FALSE, size = FALSE)
set.seed(123)
我的_数据%
聚集(“键”、“值”、-时间)%>%
ggplot(aes(x=时间,y=值,颜色=键))+
geom_线()+
刻面网格(键~,scales=“free”)+
主题_极小值()+
辅助线(颜色=假,尺寸=假)


在本例中,我希望
b
绘图具有更大的线条
size

这可以通过创建具有重复大小的新向量来实现:

linesize = rep(c(0, 1, 0), each=100) # externally define the sizes
# note that a,c will have size=0 while b size=1
这将在
geom\u线路中使用
调用:

my_data %>% 
  gather("key", "value", -time) %>%
  ggplot(aes(x = time, y = value, color = key)) +
  geom_line(size = linesize) + # here we can pass linesize
  facet_grid(key~., scales = "free") +
  theme_minimal() +
  guides(color = FALSE)

这种方法的缺点是,如果网格中有更多的绘图,则必须找出较大的绘图的位置,然后手动设置大小:
linesize