1

Possible Duplicate:
How to put labels over geom_bar in R with ggplot2

I've been searching for ways on how to put a label in the top of the bar of my qplot. Here's the picture below enter image description here

and the codes,

library(ggplot2)
library(colorRamps)
TawiTawiPop <- c(17000, 45000, 46000, 59000, 79000, 110000, 143000, 195000, 228204, 250718, 322317, 450346, 366550)
YearNames <- c("1903", "1918", "1939", "1948", "1960", "1970", "1975", "1980", "1990", "1995", "2000", "2007", "2010")

qplot(YearNames, TawiTawiPop, 
      xlab = expression(bold("Censal Year")), 
      ylab = expression(bold("Population")), 
      geom = "bar",
      stat = "identity", colour = I("red"), 
      fill = matlab.like2(13)) + theme_bw() + 
      opts(
        title = expression(bold("Tawi-Tawi Population from 1903 to 2010")),
        plot.title = theme_text(size = 18, colour = "darkblue"),
        legend.position = "none",
        panel.border = theme_rect(linetype = "dashed", colour = "red"))
        plot.title = theme_text(size = 18, colour = "darkblue")

Now I want to put a label on the top of it, like the one below. I made this in Mathematica

enter image description here

Those labels "17000, 45000, and so on", I want to have it in my qplot.

Community
  • 1
  • 1
Al-Ahmadgaid Asaad
  • 1,172
  • 5
  • 13
  • 25

1 Answers1

3
library(ggplot2)
library(colorRamps)
TawiTawiPop <- c(17000, 45000, 46000, 59000, 79000, 110000, 143000, 195000, 228204, 250718, 322317, 450346, 366550)
YearNames <- c("1903", "1918", "1939", "1948", "1960", "1970", "1975", "1980", "1990", "1995", "2000", "2007", "2010")

qplot(YearNames, TawiTawiPop, 
      xlab = expression(bold("Censal Year")), 
      ylab = expression(bold("Population")), 
      geom = "bar",
      stat = "identity", colour = I("red"), 
      fill = matlab.like2(13)) + theme_bw() + 
      opts(
        title = expression(bold("Tawi-Tawi Population from 1903 to 2010")),
        plot.title = theme_text(size = 18, colour = "darkblue"),
        legend.position = "none",
        panel.border = theme_rect(linetype = "dashed", colour = "red"),
        plot.title = theme_text(size = 18, colour = "darkblue"))+
     geom_text(aes(label = TawiTawiPop,angle=90,hjust=-0.1))
Dieter Menne
  • 10,076
  • 44
  • 67