Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created December 30, 2024 13:34
Show Gist options
  • Save abikoushi/57c7de65af5598b38f6e7f039a259055 to your computer and use it in GitHub Desktop.
Save abikoushi/57c7de65af5598b38f6e7f039a259055 to your computer and use it in GitHub Desktop.
An example of line chart with markers
library(ggplot2)
library(dplyr)
lr_default <- function(t, delay, forgetting){
(t+delay)^(-forgetting)
}
linedf <- expand.grid(delay=c(1,2), forgetting=c(0.6,0.9), t=seq(0,20, length.out=50)) %>%
mutate(lr=lr_default(t, delay, forgetting)) %>%
mutate(param = paste0("delay=",delay, ", ", "forgetting=", forgetting)) %>%
group_by(param) %>%
mutate(dummy=seq(1L, 50L, length.out=50) %% 5) %>%
ungroup()
pointdf <- dplyr::filter(linedf, dummy==1L)
ggplot(linedf, aes(x=t, y=lr,colour=param,shape=param))+
geom_line(aes(linetype = param))+
geom_point(data = pointdf)+
theme_classic(16)
ggsave("lr.jpeg")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment