I'm trying to use the scale_x_reverse()
to change the order of my axis. I wnat in the top of my plot "AR-2010", "AR2011" and so on...
But when I use scale_x_reverse()
, I got the following error
Error in -x : invalid argument to unary operator
Here is my code
ggplot()+
geom_bar(data=data_iso[order(data_iso$sex,decreasing = T),],
aes(x=yeariso,y=ratemort,fill=iso2,group=sex,alpha=sex,show.legend=F),
color="transparent",stat="identity")+
theme_bw()+
scale_alpha_manual(values=c(0.4, 1)) +
theme(legend.position="none")+
labs(color = "Country",x="")+
ylab(expression(Mortality~Rate~x~10^{5}))+
scale_fill_manual("",
values=c("turquoise","green4","#FFDB6D","chocolate2","brown2",
"royalblue","mediumorchid1","pink","lightsalmon","firebrick4"))+
geom_flag(data=df3,
aes(x = a, y = b, country = c('ar', 'br', 'cl','co','cr','gt','mx','pe')),
size = 15)+
scale_y_continuous(breaks = c(0,1e+5, 2e+5,3e+5), labels = c("0", "1", "2","3"),
limits=c(14500, 315000), oob = rescale_none)+
coord_flip()+
scale_x_reverse()
Without the scale_x_reverse()
I got the following graphic