# setwd("dir-to-work")
library(ggplot2)

All_Data <- read.csv('1D_data.txt',header = F,sep = '\t')
All_Data$V1<-factor(All_Data$V1,levels = rev(All_Data$V1))

p<- ggplot() +
  geom_bar(data = All_Data   ,aes(x = V1    ,y = V2-99 ,fill = V2 ),alpha = 0.8,  stat = 'identity',
           size=0 ,width =0.65)+
  geom_hline(yintercept = c(0.947),size=0.25,linetype='dashed',color = 'gray30')+
  theme_bw()+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        axis.text.x = element_text(size = 6), 
        axis.text.y =  element_text(size = 6),
        axis.title.x = element_text(size = 6),
        axis.title.y = element_text(size = 6),
        plot.title = element_text(hjust = 0.5,vjust = 0.5),
        legend.title = element_text(size= 6),
        legend.key.size = unit(0.2,'cm'),
        legend.text = element_text(size = 6),
        legend.background = element_blank(),
        legend.position = c(0.85,0.78),
        axis.ticks.x = element_line(size = 0.2), 
        axis.ticks.y = element_line(size = 0.2))+
  scale_y_continuous(limits = c(0,1),
                     breaks = c(0,0.2,0.4,0.6,0.8,1),
                     labels = c('99.0','99.2','99.4','99.6','99.8','100.0'),expand = c(0,0))+
  scale_fill_gradient(low = 'salmon',high = 'firebrick1')+
  xlab('Species')+
  ylab('ANI')+
  guides(fill = 'none')+
  coord_flip()
p
ggsave(filename = '1D.pdf',p,width =3,height = 1.8)
