From 5967857a9de326cf0eebe581019a52e4dc821979 Mon Sep 17 00:00:00 2001 From: Nicholas Tierney Date: Mon, 4 Feb 2019 13:59:42 -0800 Subject: [PATCH 1/5] Update `vis_cor()` to use perceptually uniform colours from `scico` package, using `scico::scico(3, palette = "vik")`. --- NEWS.md | 6 ++++++ R/vis-cor.R | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index db28a11..b146a11 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# visdat 0.5.3.9000 (2019/02/04) + +## Minor Change + +* Update `vis_cor()` to use perceptually uniform colours from `scico` package, using `scico::scico(3, palette = "vik")`. + # visdat 0.5.2.9001 (2018/12/14) ## Minor Change diff --git a/R/vis-cor.R b/R/vis-cor.R index 8999677..5b0ae78 100644 --- a/R/vis-cor.R +++ b/R/vis-cor.R @@ -42,15 +42,17 @@ vis_cor <- function(data, y = "row_2", fill = "value")) + ggplot2::geom_raster() + - ggplot2::scale_fill_gradient2(low = "steelblue", - mid = "white", - high = "salmon") + + # colours from scico::scico(3, palette = "vik") + ggplot2::scale_fill_gradient2(low = "#001260",# blue + mid = "#EAEDE9", # white + high = "#601200") + # red ggplot2::theme_minimal() + ggplot2::scale_x_discrete(position = "top") + ggplot2::labs(x = "", y = "") + ggplot2::guides(fill = ggplot2::guide_legend(title = "correlation")) + - ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, hjust = 0)) + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, + hjust = 0)) } } From 6d1b3eb3f80f7561368311e4c541cd5df088a57b Mon Sep 17 00:00:00 2001 From: Nicholas Tierney Date: Mon, 4 Feb 2019 14:03:23 -0800 Subject: [PATCH 2/5] * Update `vis_cor()` to have fixed legend values from -1 to +1 (#110) --- NEWS.md | 1 + R/vis-cor.R | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index b146a11..3c90d78 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ ## Minor Change * Update `vis_cor()` to use perceptually uniform colours from `scico` package, using `scico::scico(3, palette = "vik")`. +* Update `vis_cor()` to have fixed legend values from -1 to +1 (#110) # visdat 0.5.2.9001 (2018/12/14) diff --git a/R/vis-cor.R b/R/vis-cor.R index 5b0ae78..4f76dde 100644 --- a/R/vis-cor.R +++ b/R/vis-cor.R @@ -45,7 +45,9 @@ vis_cor <- function(data, # colours from scico::scico(3, palette = "vik") ggplot2::scale_fill_gradient2(low = "#001260",# blue mid = "#EAEDE9", # white - high = "#601200") + # red + high = "#601200", # red + breaks = c(-1, -0.5, 0, 0.5, 1), + limits = c(-1, 1)) + ggplot2::theme_minimal() + ggplot2::scale_x_discrete(position = "top") + ggplot2::labs(x = "", From 3571dbbcc3f84cc25c70c2a4c9c8cc787aa4d9fe Mon Sep 17 00:00:00 2001 From: Nicholas Tierney Date: Mon, 4 Feb 2019 14:05:54 -0800 Subject: [PATCH 3/5] update vdiffr .svg --- R/vis-cor.R | 2 +- tests/figs/vis-cor/vis-cor-vanilla.svg | 62 +++++++++++++------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/R/vis-cor.R b/R/vis-cor.R index 4f76dde..c71228a 100644 --- a/R/vis-cor.R +++ b/R/vis-cor.R @@ -52,7 +52,7 @@ vis_cor <- function(data, ggplot2::scale_x_discrete(position = "top") + ggplot2::labs(x = "", y = "") + - ggplot2::guides(fill = ggplot2::guide_legend(title = "correlation")) + + ggplot2::guides(fill = ggplot2::guide_legend(title = "Correlation")) + ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, hjust = 0)) } diff --git a/tests/figs/vis-cor/vis-cor-vanilla.svg b/tests/figs/vis-cor/vis-cor-vanilla.svg index 7850975..f6b4b84 100644 --- a/tests/figs/vis-cor/vis-cor-vanilla.svg +++ b/tests/figs/vis-cor/vis-cor-vanilla.svg @@ -13,48 +13,50 @@ - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + -Day -Month -Ozone -Solar.R -Temp -Wind +Day +Month +Ozone +Solar.R +Temp +Wind Day Month Ozone Solar.R Temp Wind -correlation - - - - --0.5 -0.0 -0.5 -1.0 +Correlation + + + + + +-1.0 +-0.5 +0.0 +0.5 +1.0 vis_cor vanilla From 24a47fdf32e76c4661f1d1a19e7849d1c1c0b11d Mon Sep 17 00:00:00 2001 From: Nicholas Tierney Date: Mon, 4 Feb 2019 14:06:05 -0800 Subject: [PATCH 4/5] version bump --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 01f26d3..376a175 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: visdat Title: Preliminary Visualisation of Data -Version: 0.5.2.9001 +Version: 0.5.3.9000 Authors@R: c( person("Nicholas", "Tierney", role = c("aut", "cre"), email = "nicholas.tierney@gmail.com", From 1f02cb93a0516110a6ce3b9415cfa0bca99aac2f Mon Sep 17 00:00:00 2001 From: Nicholas Tierney Date: Mon, 4 Feb 2019 14:10:06 -0800 Subject: [PATCH 5/5] clean up NEWS file and reference SO thread that resolves #110 --- NEWS.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/NEWS.md b/NEWS.md index 3c90d78..ea044ce 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,20 +3,10 @@ ## Minor Change * Update `vis_cor()` to use perceptually uniform colours from `scico` package, using `scico::scico(3, palette = "vik")`. -* Update `vis_cor()` to have fixed legend values from -1 to +1 (#110) - -# visdat 0.5.2.9001 (2018/12/14) - -## Minor Change - +* Update `vis_cor()` to have fixed legend values from -1 to +1 (#110) using + options `breaks` and `limits`. Special thanks to [this SO thread for the answer](https://stackoverflow.com/questions/24265652/label-minimum-and-maximum-of-scale-fill-gradient-legend-with-text-ggplot2) * Uses `glue` and `glue_collapse()` instead of `paste` and `paste0` -# visdat 0.5.2.9000 (2018/12/12) - -## Minor Change - -* Version bump to dev version - # visdat 0.5.2 (2018/12/06) "Youth, The Midnight, Kids" ## Minor Change