教程
handout_ggplot2.pdf 非常详细
ggplot-lecture,PPT:Introduction to ggplot2
实例
chart_example
- 柱图 bar 、multibar、stacked_bar、hist_bar
- 面积图 stacked_area
- 曲线图 symbol_line
散点图
通过 cut / ggplot 迅速画出 按时段 week / month 统计图
见:Plot Weekly or Monthly Totals in R
切 week / month :
log$Month <- as.Date(cut(log$Date, breaks = "month"))
log$Week <- as.Date(cut(log$Date, breaks = "week", start.on.monday = FALSE))
统计并画图:
ggplot(data = log,
aes(Month, Quantity)) +
stat_summary(
fun.y = sum, # adds up all observations for the month
geom = "bar") + # or "line"
scale_x_date(
labels = date_format("%Y-%m"),
breaks = "1 month") # custom x-axis labels
没有评论:
发表评论