#Create data frame
Country <- c("Vietnam", "Thailand", "Malaysia", "Indonesia", "Singapore")
Publication <- c(17178, 42914, 71229, 19585, 69883)
dat <- data.frame(Country, Publication)
#Plotting
library(ggplot2); library(ggthemes)
## Registered S3 methods overwritten by 'ggplot2':
## method from
## [.quosures rlang
## c.quosures rlang
## print.quosures rlang
p <- ggplot(data=dat, aes(x= Country, y= Publication, fill=Country,
col=Country)) +
geom_bar(stat="identity")+
theme_economist(base_size = 8, base_family="sans", horizontal = TRUE)
p
#Reorder Barplot
p <- ggplot(data=dat, aes(x= reorder(Country, Publication),
y= Publication, fill=Country,
col=Country)) +
geom_bar(stat="identity")+
theme_economist(base_size = 8, base_family="sans", horizontal = TRUE) +
xlab("Quoc gia") +
ylab("So cong bo")
p
#Add text to bar
p <- ggplot(data=dat, aes(x= reorder(Country, Publication),
y= Publication, fill=Country,
col=Country)) +
geom_bar(stat="identity")+
theme_economist(base_size = 8, base_family="sans", horizontal = TRUE) +
geom_text(aes(label=Publication), size=5, angle=0, col="black",
position=position_stack(vjust=0.5))
p
#Change color & add axis labels
p <- ggplot(data=dat, aes(x= reorder(Country, Publication),
y= Publication, fill=Country,
col=Country)) +
geom_bar(stat="identity") +
theme_economist(base_size = 8, base_family="sans", horizontal = TRUE) +
geom_text(aes(label=Publication), size=5, angle=0, col="black",
position=position_stack(vjust=0.5))+
scale_fill_manual(values=c("#7CFC00",
"#008000", "#FFD700", "#FF4500", "#8B0000")) +
theme(legend.position="none") +
xlab("Qu\u1ED1c gia") +
ylab("S\u1ED1 c\u00F4ng b\u1ED1")
p