项目作者: nacnudus

项目描述 :
geom_straw for ggplot2
高级语言: R
项目地址: git://github.com/nacnudus/ggstraw.git
创建时间: 2017-02-23T20:40:04Z
项目社区:https://github.com/nacnudus/ggstraw

开源协议:Other

下载


ggstraw

One damned thing after another

A geom for the ‘ggplot2’ package to visualize the difference between two
events related to one object, e.g. scheduled and actual arrival.

Installation

You can install ggstraw from github with:

  1. # install.packages("devtools")
  2. devtools::install_github("nacnudus/ggstraw")

Example

  1. library(ggplot2)
  2. library(ggstraw)
  3. example(geom_straw)
  4. #>
  5. #> gm_str> # Plot a subset of the nycflights13 data
  6. #> gm_str> library(ggplot2)
  7. #>
  8. #> gm_str> ggplot(ggstraw::flights,
  9. #> gm_str+ aes(sched_dep_time, carrier, xend = dep_time, colour = late)) +
  10. #> gm_str+ geom_straw() +
  11. #> gm_str+ scale_colour_manual("Late", values = c("black", "red")) +
  12. #> gm_str+ xlab("") +
  13. #> gm_str+ ylab("Carrier") +
  14. #> gm_str+ ggtitle("Departure times from New York to Boston", sub = "Scheduled vs actual") +
  15. #> gm_str+ theme_minimal() +
  16. #> gm_str+ theme(panel.grid = element_blank())

  1. #>
  2. #> gm_str> # Plot a subset of the London Underground Metropolitan Line timetable
  3. #> gm_str> ggplot(ggstraw::timetable, aes(x = departure, xend = arrival, y = day)) +
  4. #> gm_str+ geom_straw() +
  5. #> gm_str+ xlab("") +
  6. #> gm_str+ ylab("") +
  7. #> gm_str+ ggtitle("Metropolitan timetable from Harrow-on-the-Hill to Moor Park",
  8. #> gm_str+ subtitle = "Scheduled departure time (bottom) and scheduled arrival time (top)") +
  9. #> gm_str+ theme_minimal() +
  10. #> gm_str+ theme(panel.grid = element_blank())