library(ggplot2)
xx <- seq(from = 0, to = 20, length.out = 101)
blend_mat <- blended_transition(xx, u = 10, eps = 3, .gradient = TRUE)
ggplot(
data.frame(
x = rep(xx, 2L),
fun = rep(c("p", "q"), each = length(xx)),
y = as.numeric(blend_mat),
relevant = c(xx <= 13, xx >= 7)
),
aes(x = x, y = y, color = fun, linetype = relevant)
) %+%
geom_line() %+%
theme_bw() %+%
theme(
legend.position = "bottom", legend.box = "horizontal"
) %+%
guides(color = guide_legend(direction = "horizontal", title = ""), linetype = guide_none()) %+%
scale_linetype_manual(values = c("TRUE" = 1, "FALSE" = 3))
ggplot(
data.frame(
x = rep(xx, 2L),
fun = rep(c("p'", "q'"), each = length(xx)),
y = as.numeric(attr(blend_mat, "gradient")),
relevant = c(xx <= 13, xx >= 7)
),
aes(x = x, y = y, color = fun, linetype = relevant)
) %+%
geom_line() %+%
theme_bw() %+%
theme(
legend.position = "bottom", legend.box = "horizontal"
) %+%
guides(color = guide_legend(direction = "horizontal", title = ""), linetype = guide_none()) %+%
scale_linetype_manual(values = c("TRUE" = 1, "FALSE" = 3))
Run the code above in your browser using DataLab