ggplots step by step
library(ggplot2)
# source("./theme_kr_HCR.R")
gg.title <- "Income and Consumer Expenditure for each Tenth (2011 4/4)"
x.lab <- "Income Tenth"
y.lab <- "Amount in Thousand Won"
Income.Amount <- hh.econ.10th.melt[hh.econ.10th.melt$Income.Expense == "Market Income", "Amount"]
# legend.lab <- c("Market Income", "Consumer Spending", "Disposable Income")
# (g1 <- ggplot(hh.econ.melt, aes(x = Income.Fifth, y = Amount, fill = Income.Expense, colour = Income.Expense, group = Income.Expense)) +
# geom_bar(stat = "identity"))
# (g1 <- ggplot(hh.econ.melt, aes(x = Income.Fifth, y = Amount, fill = Income.Expense, colour = Income.Expense, group = Income.Expense)) +
# geom_bar(stat = "identity", position = "dodge"))
(g1 <- ggplot(hh.econ.10th.melt, aes(x = Income.Tenths,
y = Amount,
fill = Income.Expense)) +
geom_bar(stat = "identity"))

(g1 <- ggplot(hh.econ.10th.melt, aes(x = Income.Tenths,
y = Amount,
fill = Income.Expense)) +
geom_bar(stat = "identity",
position = "dodge"))

(g2 <- g1 +
theme_bw())

(g3.1 <- g2 +
geom_line(aes(group = Income.Expense, linetype = Income.Expense),
position = position_dodge(width = 1.0),
size = 1,
na.rm = TRUE,
show.legend = FALSE))

(g3.2 <- g3.1 +
geom_point(aes(group = Income.Expense, shape = Income.Expense),
position = position_dodge(width = 1.0),
size = 3,
stroke = 1.2,
na.rm = TRUE,
show.legend = FALSE))

(g4 <- g3.2 +
scale_y_continuous(breaks = Income.Amount,
labels = format(Income.Amount/1000,
digits = 1,
nsmall = 1,
big.mark = ",")) +
scale_linetype_manual(values = c("blank", "solid", "solid")) +
scale_shape_manual(values = c(NA, 4, 4)) +
labs(title = gg.title,
x = x.lab,
y = y.lab,
fill = "Income or Expenses"))

(g5 <- g4 +
theme(legend.position = c(0.2, 0.8)))

(g6 <- g5 +
scale_fill_grey(start = 1/6, end = 5/6) +
scale_colour_grey(start = 1/6, end = 5/6))

(g7 <- g5 +
scale_fill_manual(values = c("blue", "turquoise1", "red")))

(g8 <- g7 +
# theme(legend.key = element_blank()))
# theme(legend.key = element_rect(fill = "black", colour = "white")))
theme(legend.box.background = element_rect()))

ggsave("../pics/no_trickle_down_effects_10th.png")
## Saving 9 x 5.1 in image