country=c("Vietnam","Thailand","Malaysia","Indonesia","Singapore")
Pubcations=c(17178,42914,71229,19585,69883)
dat=data.frame(country, Pubcations)
dat
## country Pubcations
## 1 Vietnam 17178
## 2 Thailand 42914
## 3 Malaysia 71229
## 4 Indonesia 19585
## 5 Singapore 69883
library(ggplot2)
## Registered S3 methods overwritten by 'ggplot2':
## method from
## [.quosures rlang
## c.quosures rlang
## print.quosures rlang
p=ggplot(data=dat,aes(x=country,y=Pubcations))
p+geom_bar(stat = "identity")
# To mau cho bieu do
p=ggplot(data=dat,aes(x=country,y=Pubcations,fill=country, col=country))
p+geom_bar(stat = "identity")
## bo mau legend
p+geom_bar(stat = "identity")+theme(legend.position = "none")
p+geom_bar(stat = "identity")
##
p=ggplot(data=dat,aes(x=reorder(country,Pubcations),y=Pubcations, fill=country, col=country))
p+geom_bar(stat="identity")+theme_bw()+theme(legend.position = "none")
p+geom_bar(stat="identity")+theme_bw()+theme(legend.position = "none")+xlab("country")
##Them số liệu
p=ggplot(data=dat,aes(x=reorder(country,Pubcations),y=Pubcations, fill=country, col=country, label=Pubcations))
p+geom_bar(stat="identity")+ geom_text(size=3,color="white",position= position_stack(vjust = 0.5))