# 创建数据
mydata <- data.frame(var =c("hsa","mmu","rat",'cat',"dog","pig",'rabbit','monkey'),
                     value = c(8,10,6,5,3,4,4,2) )
mydata <- mydata[order(mydata$value),]
mydata$var <- factor(mydata$var,levels = mydata$var )

library(ggplot2)
ggplot(mydata,aes(x=var,y=value,fill= value ))+
  geom_bar(width=1,
           stat = "identity",
           colour="white" ) +
  scale_fill_gradient(low = "pink", high = "red4")+
  # 数值标签、颜色、字号
  geom_text(aes(y=value, label=value),
            color="gray50",size=10) +

  coord_polar(theta = "x",start=0) +
  theme_bw()+ # 主题
  theme(axis.text.x  = element_text( size=20, colour="black", angle= 0 ),
        axis.title = element_text(size = 25),
        axis.title.y = element_text(size = 25, angle = 90, vjust = 0.5),
        axis.ticks.y = element_blank(),
        axis.text.y  = element_blank(),
        panel.border = element_blank()
        )
Avatar photo

作者 xian

发表回复