GGPLOT2 - Remove duplicated text

Hi. From this code I got the plot showed below:

> 
> pr Date              events                                                                     itestcenter                Count
> 2020-03-01 	  Only test of hospitalized patients with respiratory symptoms	                      0                        752
> 2020-04-01	  Increased test activity including the primary sector                                0                        37593
> 2020-04-20	  Test of all hospitalized patients and everyone with symptoms                        0                      8234
> 2020-04-20 	 Test of all hospitalized patients and everyone with symptoms	                      1                        385
> 2020-05-19	   Acces to test for all citizens	                                                  0                     117266
> 2020-05-19	    Acces to test for all citizens	                                                  1                      35072
> 2020-08-07  	Local outbreak in Aarhus with excessive testing	                                      0                    112118
> 2020-08-07  	Local outbreak in Aarhus with excessive testing	                                      1                     163759
> 2020-08-28	        Introduction of systematic testing of staff in selected sectors	              0                     19552
> 2020-08-28	         Introduction of systematic testing of staff in selected sectors	          1                     16415

ggplot(figur2events,aes(x=prdate,y=count,group=iTESTCENTER, color=iTESTCENTER))+
  geom_point(size=1)+
 scale_colour_discrete(name  ="Group",
       breaks=c(1, 0),
      labels=c("Samfundsspor(TCD)", "Sundhedsspor(KMA)"))+
  geom_segment(aes(x=prdate, xend=prdate,y=0, yend=count),lty=1)+
  geom_text(aes(label=events),angle=90,vjust=-0.1, hjust=-0.6, size=3, check_overlap = TRUE)+
 scale_x_date(date_breaks = "1 week", date_labels = "%d/%m")+
theme_bw() + 
  theme(plot.title = element_text(hjust=0.5))+
theme(panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"))+ 
  ggtitle("Dates of changed test activity with number of tests from Samfundsspor and Sundhedsspor") +
  xlab("Day/Month") + ylab("Number of tests") + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1, color="black"))+
  labs( color="") + theme(legend.position = "right")+
  geom_point(size = 1.5) +
  ggalt::geom_xspline() +
  scale_y_continuous(expand = c(0, 0))+
  theme_classic()

HOw can I remove the Blue text that are duplicated - also the last text on the last point is not shown as there are no space - how can I improve that so its label will be shown ?

Hi!

To help us help you, could you please turn this into a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

1 Like