-
Notifications
You must be signed in to change notification settings - Fork 35
/
学术图表案例:南丁格尔玫瑰图.R
38 lines (33 loc) · 1.45 KB
/
学术图表案例:南丁格尔玫瑰图.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
library(ggplot2)
library(zoo)
library(reshape2)
df<-read.csv("rosegraph.csv",stringsAsFactors = FALSE)
df$date <-as.Date(paste(df$date,1,sep="-"),"%Y-%m-%d")
df_melt<-melt(df,id.vars=c("date","total"))
myAngle <-seq(-20,-340,length.out = 12)
ggplot(df_melt, aes(x =factor(date), y=value, fill = variable)) +
geom_bar(width = 0.8, size=0.1,stat="identity",
position="identity", color="black",alpha=1)+
scale_y_sqrt()+
scale_x_discrete(labels=format(df$date,"%y-%m"))+
#coord_polar(start=3*pi/2)+ #¼«×ø±ê±ä»»
#ggtitle("Causes of Mortality in the Crimean War:1854.4~1855.3") +
xlab("")+
theme_light()+
theme(#axis.text.x=element_text(size = 13,colour="black",angle =90+ myAngle),
panel.border = element_blank(),
panel.grid.major.x = element_blank(),
axis.line.y =element_blank(),
axis.text = element_text(color='black'))
ggplot(df_melt, aes(x =factor(date), y=value, fill = variable)) +
geom_bar(width = 1, size=0.1,stat="identity",
position="identity", color="black",alpha=1)+
scale_y_sqrt()+
scale_x_discrete(labels=format(df$date,"%y-%m"))+
coord_polar(start=3*pi/2)+ #¼«×ø±ê±ä»»
ggtitle("Causes of Mortality in the Crimean War:1854.4~1855.3") +
xlab("")+
theme_light()+
theme(axis.text.x=element_text(size = 13,colour="black",angle =90+ myAngle),
panel.grid.major.x = element_line(color='gray70'),
panel.grid.major.y = element_line(color='gray70'))