-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
How can I show the name of the dotted red line underneath the x axis ? I would like to put the name of this vertical line at the same level of the date or maybe lower. Maybe the annotate element is not the right one but with "geom_text" it's even worst. Here is the shiny app in question where I just don't put the names of this line.
https://dancelestini.shinyapps.io/Swiss-COVID19/
library(tidyverse)
library(readxl)
library(plotly)
library(ggplot2)
df = read_excel("covid-19.3.xlsx", sheet = 1)
df$Date = as.Date(df$Date,format = "%Y-%m-%d")
p = ggplot(data = df, aes(Date, `Nombre de cas`))+
geom_col(size = 0.1)+
labs(title = "Swiss COVID-19 cases per day",y="New observation per day", x = "Date")+
theme(plot.title = element_text(hjust = 0.5, color = "red", size =14, face="bold.italic"),
axis.title = element_text(face = "bold"),
plot.margin = margin(20,20,20,20, unit = "pt"))+
geom_vline(xintercept = as.numeric(as.Date("2020-05-11")), color = "red", linetype = "dotted", size = 0.5)+
annotate("text",x=as.Date("2020-05-11"),y = -100,label = "name",color = "black",size = 5)+
coord_cartesian(clip = "off")
ggplotly(p)
Metadata
Metadata
Assignees
Labels
No labels