Open ywj-xchh opened 4 years ago
I am trying to use ggplot to create to a point plot with Date on x-axis and freq on y-axis. The dates on the x-axis are overlapping. This makes the point plot difficult to read. Is there any way to solve this problem?
ggplot
Date
freq
library(tidyverse) count_date1 <- tribble(~Date, ~freq, "13-04-2015", "24", "13-05-2015", "12", "13-06-2015", "32", "14-04-2015", "23", "14-05-2015", "15", "14-06-2015", "16", "15-04-2015", "12", "15-05-2015", "12", "15-06-2015", "34", "16-04-2015", "20", "16-05-2015", "16", "16-06-2015", "29", "17-04-2015", "21", "17-05-2015", "7", "17-06-2015", "32", "18-04-2015", "8", "18-05-2015", "14", "18-06-2015", "47", "19-04-2015", "9", "19-05-2015", "12", "19-06-2015", "29", "20-04-2015", "20", "20-05-2015", "15", "20-06-2015", "16", "21-04-2015", "12", "21-05-2015", "17", "21-06-2015", "12", "22-04-2015", "22", "22-05-2015", "14", "22-06-2015", "30", "23-04-2015", "23", "23-05-2015", "12", "23-06-2015", "190", "24-04-2015", "24", "24-05-2015", "7", "24-06-2015", "218", "25-04-2015", "16", "25-05-2015", "12", "25-06-2015", "98", "26-04-2015", "8", "26-05-2015", "27", "26-06-2015", "55", "27-04-2015", "25", "27-05-2015", "17", "27-06-2015", "39", "28-04-2015", "26", "28-05-2015", "26", "28-06-2015", "27", "29-04-2015", "22", "29-05-2015", "14", "29-06-2015", "51", "30-04-2015", "24", "30-05-2015", "9", "30-06-2015", "53", "31-05-2015", "10", "4/1/2015", "18", "4/10/2015", "21", "4/11/2015", "5", "4/12/2015", "15", "4/2/2015", "27", "4/3/2015", "15", "4/4/2015", "12", "4/5/2015", "6", "4/6/2015", "13", "4/7/2015", "25", "4/8/2015", "28", "4/9/2015", "21", "5/1/2015", "12", "5/10/2015", "7", "5/11/2015", "12", "5/12/2015", "7", "5/2/2015", "7", "5/3/2015", "5", "5/4/2015", "12", "5/5/2015", "14", "5/6/2015", "14", "5/7/2015", "15", "5/8/2015", "15", "5/9/2015", "11", "6/1/2015", "25", "6/10/2015", "25", "6/11/2015", "21", "6/12/2015", "43", "6/2/2015", "25", "6/3/2015", "25", "6/4/2015", "12", "6/5/2015", "29", "6/6/2015", "11", "6/7/2015", "9", "6/8/2015", "24", "6/9/2015", "23") ggplot(count_date1, aes(Date,freq)) + geom_point() + geom_line(aes(group=Date)) + xlab("Date") + ylab("No. of Complaints") #> geom_path: Each group consists of only one observation. Do you need to adjust #> the group aesthetic?
Created on 2020-08-12 by the reprex package (v0.3.0)
I am trying to use
ggplot
to create to a point plot withDate
on x-axis andfreq
on y-axis. The dates on the x-axis are overlapping. This makes the point plot difficult to read. Is there any way to solve this problem?Created on 2020-08-12 by the reprex package (v0.3.0)
Session info
``` r devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.0.2 (2020-06-22) #> os macOS Catalina 10.15.5 #> system x86_64, darwin17.0 #> ui X11 #> language (EN) #> collate en_AU.UTF-8 #> ctype en_AU.UTF-8 #> tz Australia/Melbourne #> date 2020-08-12 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.2) #> backports 1.1.8 2020-06-17 [1] CRAN (R 4.0.2) #> blob 1.2.1 2020-01-20 [1] CRAN (R 4.0.2) #> broom 0.7.0 2020-07-09 [1] CRAN (R 4.0.2) #> callr 3.4.3 2020-03-28 [1] CRAN (R 4.0.2) #> cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.0.2) #> cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.2) #> colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.2) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.2) #> curl 4.3 2019-12-02 [1] CRAN (R 4.0.1) #> DBI 1.1.0 2019-12-15 [1] CRAN (R 4.0.2) #> dbplyr 1.4.4 2020-05-27 [1] CRAN (R 4.0.2) #> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.2) #> devtools 2.3.1 2020-07-21 [1] CRAN (R 4.0.2) #> digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.2) #> dplyr * 1.0.1 2020-07-31 [1] CRAN (R 4.0.2) #> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.2) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.1) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.2) #> farver 2.0.3 2020-01-16 [1] CRAN (R 4.0.2) #> forcats * 0.5.0 2020-03-01 [1] CRAN (R 4.0.2) #> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2) #> generics 0.0.2 2018-11-29 [1] CRAN (R 4.0.2) #> ggplot2 * 3.3.2 2020-06-19 [1] CRAN (R 4.0.2) #> glue 1.4.1 2020-05-13 [1] CRAN (R 4.0.2) #> gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.2) #> haven 2.3.1 2020-06-01 [1] CRAN (R 4.0.2) #> highr 0.8 2019-03-20 [1] CRAN (R 4.0.2) #> hms 0.5.3 2020-01-08 [1] CRAN (R 4.0.2) #> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.2) #> httr 1.4.2 2020-07-20 [1] CRAN (R 4.0.2) #> jsonlite 1.7.0 2020-06-25 [1] CRAN (R 4.0.2) #> knitr 1.29 2020-06-23 [1] CRAN (R 4.0.2) #> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.2) #> lubridate 1.7.9 2020-06-08 [1] CRAN (R 4.0.2) #> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.2) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.2) #> mime 0.9 2020-02-04 [1] CRAN (R 4.0.2) #> modelr 0.1.8 2020-05-19 [1] CRAN (R 4.0.2) #> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.2) #> pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.2) #> pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.2) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2) #> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.2) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.2) #> processx 3.4.3 2020-07-05 [1] CRAN (R 4.0.2) #> ps 1.3.3 2020-05-08 [1] CRAN (R 4.0.2) #> purrr * 0.3.4 2020-04-17 [1] CRAN (R 4.0.2) #> R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.2) #> Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.2) #> readr * 1.3.1 2018-12-21 [1] CRAN (R 4.0.2) #> readxl 1.3.1 2019-03-13 [1] CRAN (R 4.0.2) #> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.2) #> reprex 0.3.0 2019-05-16 [1] CRAN (R 4.0.2) #> rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.2) #> rmarkdown 2.3 2020-06-18 [1] CRAN (R 4.0.2) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.2) #> rvest 0.3.6 2020-07-25 [1] CRAN (R 4.0.2) #> scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.2) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.2) #> stringi 1.4.6 2020-02-17 [1] CRAN (R 4.0.2) #> stringr * 1.4.0 2019-02-10 [1] CRAN (R 4.0.2) #> testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.2) #> tibble * 3.0.3 2020-07-10 [1] CRAN (R 4.0.2) #> tidyr * 1.1.1 2020-07-31 [1] CRAN (R 4.0.2) #> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.2) #> tidyverse * 1.3.0 2019-11-21 [1] CRAN (R 4.0.2) #> usethis 1.6.1 2020-04-29 [1] CRAN (R 4.0.2) #> vctrs 0.3.2 2020-07-15 [1] CRAN (R 4.0.2) #> withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.2) #> xfun 0.16 2020-07-24 [1] CRAN (R 4.0.2) #> xml2 1.3.2 2020-04-23 [1] CRAN (R 4.0.2) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.2) #> #> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library ```