Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make vis_cor have a consistent legend between -1 and 1 #112

Merged
merged 5 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 4 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# visdat 0.5.2.9001 (2018/12/14)
# 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")`.
* 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
Expand Down
14 changes: 9 additions & 5 deletions R/vis-cor.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,19 @@ 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
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 = "",
y = "") +
ggplot2::guides(fill = ggplot2::guide_legend(title = "correlation")) +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, hjust = 0))
ggplot2::guides(fill = ggplot2::guide_legend(title = "Correlation")) +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45,
hjust = 0))
}
}

Expand Down
Loading