etc5523-2020 / exercise2C

For students to submit their reproducible example in the issue
0 stars 0 forks source link

Congested x axis! How to set up the proper size of x axis #6

Open jluo0015 opened 4 years ago

jluo0015 commented 4 years ago

Hi, I am trying to plot the date and frequency, but I found that the x-axis is congested and it is hard to read. Meanwhile, there is no line chart in the plot, but I have written the geom_line in r chunk. Can somebody help me to set up the proper size of the x-axis and explain why no line chart in there? Thank you.

library(tibble)
library(ggplot2)
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,
                       "4-06-2015", 16,
                       "4/1/2015", 18,
                       "4/10/2015", 21,
                       "4/11/2015", 5,
                       "4/12/2015", 15,
                       "4/2/2015", 27,
                       "4/7/2015", 25)

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)

Session info ``` r sessionInfo() #> R version 4.0.2 (2020-06-22) #> Platform: x86_64-w64-mingw32/x64 (64-bit) #> Running under: Windows 10 x64 (build 18362) #> #> Matrix products: default #> #> locale: #> [1] LC_COLLATE=Chinese (Simplified)_China.936 #> [2] LC_CTYPE=Chinese (Simplified)_China.936 #> [3] LC_MONETARY=Chinese (Simplified)_China.936 #> [4] LC_NUMERIC=C #> [5] LC_TIME=Chinese (Simplified)_China.936 #> system code page: 1252 #> #> attached base packages: #> [1] stats graphics grDevices utils datasets methods base #> #> other attached packages: #> [1] ggplot2_3.3.2 tibble_3.0.3 #> #> loaded via a namespace (and not attached): #> [1] xml2_1.3.2 knitr_1.29 magrittr_1.5 tidyselect_1.1.0 #> [5] munsell_0.5.0 colorspace_1.4-1 R6_2.4.1 rlang_0.4.7 #> [9] httr_1.4.2 stringr_1.4.0 highr_0.8 dplyr_1.0.1 #> [13] tools_4.0.2 grid_4.0.2 gtable_0.3.0 xfun_0.16 #> [17] withr_2.2.0 htmltools_0.5.0 ellipsis_0.3.1 yaml_2.2.1 #> [21] digest_0.6.25 lifecycle_0.2.0 crayon_1.3.4 farver_2.0.3 #> [25] purrr_0.3.4 vctrs_0.3.2 curl_4.3 mime_0.9 #> [29] glue_1.4.1 evaluate_0.14 rmarkdown_2.3 labeling_0.3 #> [33] stringi_1.4.6 compiler_4.0.2 pillar_1.4.6 generics_0.0.2 #> [37] scales_1.1.1 pkgconfig_2.0.3 ```