Europe", "Americas", "Asia Pacific", "East EU Cemt Asia", "MENA", "SSA"), labels = c( "OECD", "Americas", "Asia & \n Oceania", "Central & \n Eastern Europe", "Middle East & \n North Africa", "Sub-Saharan \n Africa")) # labels labels <- c( "Congo", "Afghanistan", "Sudan", "Myanmar", "Iraq", "Venezuela", "Russia", "Argentina", "Brazil", "Italy", "South Africa", "Cape Verde", "Bhutan", "Botswana", "Britian", "New Zealand", "Greece", "China", "India", "Rwanda", "Spain", "France", "United States", "Japan", "Norway", "Singapore", "Barbados", "Germany") # plotting p1 <- ggplot(ec, aes( x=CPI, y=HDI, color=Region)) + geom_smooth( aes( fill= "red"), method= "lm", formula=y ~ poly(x, 2), se=F, color= "red", size= 0.6) + geom_point( shape= 21, size= 3, stroke= 0.8, fill= "white") + geom_text_repel( data= subset(ec,Country %in% labels), aes( label=Country), color= "black", box.padding= unit( 1, 'lines'), segment.size= 0.25, size= 3, family= "Gidole") + scale_x_continuous( name= "Corruption Perceptions Index, 2011 (10=least corrupt)", breaks= 1 : 10, limits= c( 1, 10)) + scale_y_continuous( name= "Human Development Index, 2011 (1=best)", breaks= seq( from= 0, to= 1, by= 0.1), limits= c( 0.2, 1)) + scale_color_manual( values= c( "#23576E", "#099FDB", "#29B00E", "#208F84", "#F55840", "#924F3E")) + scale_fill_manual( name= "trend", values= "red", labels= expression( paste(R ^ 2, "=52%"))) + labs( title= "Corruption and human development", caption= "Sources: Transparency International UN Human Development Report") + guides( color= guide_legend( nrow= 1)) + theme_bw( base_family= "Gidole") + theme( legend.position= "top", = element_blank(), = element_blank(), panel.background= element_blank(), panel.border= element_blank(), legend.title= element_blank(), axis.title= element_text( face= "italic"), = element_blank(), = element_line( color= "grey60"), plot.title= element_text( face= "bold"), plot.caption= element_text( hjust= 0, size= 8)) p1 3 WSJ Heatmap # read data ec <- read.csv( "assets/data_economist.csv", header=T) # refactor ec $Region <- factor(ec $Region, levels = c( "EU W.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |