Reputation: 8364
I'd like to change the size of a particular line, inside a single facet_grid
, and keep the others unchanged. This in order to "highlight" more a line.
Fake data:
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)
In this example, I'd like the b
plot to have a bigger line size
.
Upvotes: 1
Views: 506
Reputation: 8364
This can be achieved by creating a new vector having the repeated sizes:
linesize = rep(c(0, 1, 0), each=100) # externally define the sizes
# note that a,c will have size=0 while b size=1
This will be used inside the geom_line
call:
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)
Upvotes: 2