Skip to content

Instantly share code, notes, and snippets.

@schochastics
Created February 10, 2023 14:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schochastics/bdb8d564a18e683eda00eaedbe6b35cf to your computer and use it in GitHub Desktop.
Save schochastics/bdb8d564a18e683eda00eaedbe6b35cf to your computer and use it in GitHub Desktop.
recreate chart style of daily mail
library(ggplot2)
library(ggpubr)
library(ggtext)
df <- data.frame(x=seq.Date(as.Date("2020-04-01"),as.Date("2022-07-01"),by="month"),y=(1:28)^2)
p <- ggplot(df, aes(x, y))+
geom_line(linewidth = 2.2,color="white",lineend = "round")+
geom_line(linewidth = 1,color="red",lineend = "round")+
scale_x_date(labels=scales::label_date("%b\n%Y"))+
theme(axis.text = element_text(size=12,color="white",face = "bold"),
axis.ticks = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.y = element_line(color="black"),
plot.title.position = "plot",
plot.title = element_textbox_simple(
size = 16, halign = 0.5,
lineheight = 1,
padding = margin(5.5, 5.5, 5.5, 5.5),
margin = margin(-5.5, -5.5, 5.5, -5.5),
fill = "red",face = "bold"
))+
labs(x="",y="",
title = " <span style = 'color:white;'>AN INTERESTING COVID 19 CHART WITH BOGUS DATA</span>")
pfinal <- ggimage::ggbackground(p, "https://europeanlung.org/wp-content/uploads/2021/04/coronavirus-1024x590.jpg")
ggsave("covid.png",pfinal)
@schochastics
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment