- library(tidyverse)
- a <- read_csv("ccc.csv")
- verticalSegment <- data_frame(x = seq(0.5, 45.5, 1), y = 0.5+2003, xend = seq(0.5, 45.5, 1), yend = 10.5+2003)
- horizonSegment <- data_frame(x = 0.5, y = seq(0.5, 10.5, 1)+2003, xend = 45.5, yend = seq(0.5, 10.5, 1)+2003)
- classSegment <- data_frame(x = c(0.6, 4.6, 14.6, 34.6), xend = c(4.4, 14.4, 34.4, 45.4), y = 11.5+2003, yend = 11.5+2003)
- classTail <- data_frame(x = c(0.6, 4.4, 4.6, 14.4, 14.6, 34.4, 34.6, 45.4),
- xend = c(0.6, 4.4, 4.6, 14.4, 14.6, 34.4, 34.6, 45.4),
- y = 11.5+2003, yend = 11+2003)
- b <- a %>% spread(key=Year,value=Val) %>%
- rbind(.,c("z"," ",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA)) %>% gather("Year","Val",3:12) %>%
- mutate(Name = factor(Name,levels = c("HFMD","Influenza H1N1","Influenza H5N1","Influenza H7N9","Brucellosis","Hepatitis C","Hepatitis E","HIV Infection","Hydatid disease","Leprosy","Mumps","OID","Syphilis","Schistosomiasis","Haemorrhagic fever","Hepatitis A","Anthrax","Gonorrhoea","Cholera","ECM","Encephalitis","BD","AD","NT","Filariasis","Leptospirosis","Malaria","Paratyphoid","Pertussis","Plague","Rabies","Tuberculosis","Typhoid","Typhus","AHC","Dengue","Diptheria","Hepatitis B","Kala-azar","Measles","Poliomyelitis","Rubella","Seansonal influenza","Scarlet fever","SARS"," ")),Year = as.numeric(Year),Val = as.numeric(Val))
- ggplot(b) + geom_tile(aes(x = Name, y = Year, fill = Val)) +
- geom_segment(data = horizonSegment, aes(x = x, y = y, xend = xend, yend = yend)) +
- geom_segment(data = verticalSegment, aes(x = x, y = y, xend = xend, yend = yend)) +
- geom_segment(data = classSegment , aes(x = x, y = y, xend = xend, yend = yend)) +
- geom_segment(data = classTail, aes(x = x, y = y, xend = xend, yend = yend)) +
- ylim(c(2000, 2016)) + annotate("text", x = " ", y = 2004:2013, label = as.character(2004:2013)) +
- labs(x = NULL, y = NULL) + annotate("text", x = c(3, 11, 27, 40), y = 2014, label = LETTERS[1:4]) +
- coord_polar(theta = "x",start = pi/360*9.5) + scale_fill_gradient(high = "#F77400", low = "yellow", na.value = "white") +
- theme_classic() + theme(axis.line = element_blank(), axis.text.y = element_blank(), axis.ticks = element_blank(), legend.position = c(0,1))
复制代码
|