1

重複の可能性:
ggplot2 を使用して R で geom_bar にラベルを付ける方法

qplot のバーの上部にラベルを付ける方法を探していました。これが下の写真です ここに画像の説明を入力

そしてコード、

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")

次に、下のようなラベルを上に置きたいと思います。私はMathematicaでこれを作りました

ここに画像の説明を入力

それらのラベル「17000、45000など」をqplotに入れたいです。

4

1 に答える 1

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))
于 2012-05-16T07:56:45.090 に答える