Guest User

Untitled

a guest
Jul 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. library(ggplot2)
  2.  
  3. sparkLinePlot <- function(df, plot.file) {
  4.  
  5. highest <- subset(df, outcomes == max(outcomes))
  6. lowest <- subset(df, outcomes == min(outcomes))
  7.  
  8. p <- ggplot(df, aes(x=date, y=outcomes)) +
  9. geom_line() +
  10. opts(panel.border = theme_rect(linetype = 0),
  11. panel.background = theme_rect(colour = "white"),
  12. panel.grid.major = theme_blank(),
  13. panel.grid.minor = theme_blank(),
  14. axis.text.x = theme_blank(),
  15. axis.text.y = theme_blank(),
  16. axis.ticks = theme_blank()) +
  17. ylab("") +
  18. geom_point(data = lowest, size = 3, colour = alpha("red", 0.5)) +
  19. geom_point(data = highest, size = 3, colour = alpha("blue", 0.5)) +
  20. scale_y_continuous(formatter = comma) +
  21. scale_x_date(name = "", major="months", minor="weeks", format="%b-%d")
  22.  
  23. ggsave(file = paste(plot.file, ".svg", sep=""), width = 3, height = 2)
  24.  
  25. }
Add Comment
Please, Sign In to add comment