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

Do different settings for symmetric= and center= in plotHeatmap ever make sense? #134

Open
LTLA opened this issue Nov 24, 2020 · 1 comment

Comments

@LTLA
Copy link
Collaborator

LTLA commented Nov 24, 2020

Discuss (3 marks).

@alanocallaghan
Copy link
Owner

symmetric=TRUE and center=FALSE doesn't ever make sense to me.

For the converse I think you can come up with contrived cases where it ends up with a marginally less bad colour scale but in general no, I don't think it makes sense. It's enough of an edge case that it probably doesn't need to be handled by default. Better to have vaguely sensible behaviour in 90% of cases than to try to catch everything

    
library("ggplot2")
library("RColorBrewer")
library("viridis")
#> Loading required package: viridisLite
x <- rnorm(100)
x[1:20] <- abs(x[1:20])
x[80] <- -5

plot_colors <- function(x, symmetric = FALSE) {
    x <- x - mean(x)
    ggplot() +
        aes(1:length(x), x, color = x) +
        geom_point() +
        scale_color_gradientn(
            colors=if (symmetric) brewer.pal(9, "RdYlBu") else viridis(9),
            limits = if (symmetric) c(-max(abs(x)), max(abs(x))) else range(x)
        )
}
plot_colors(x, symmetric=TRUE)

plot_colors(x, symmetric=FALSE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants