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

alpha in colors #37

Open
raredd opened this issue Jul 15, 2015 · 1 comment
Open

alpha in colors #37

raredd opened this issue Jul 15, 2015 · 1 comment

Comments

@raredd
Copy link

raredd commented Jul 15, 2015

Hi, Karl, this probably is not qtlcharts-specific, but ?heat.colors and the other palettes default to using an alpha parameter (which can be removed with alpha = NULL), but with any values, 00-ff, I get results like this:

library('qtlcharts')
data(geneExpr)
iplotCorr(geneExpr$expr, geneExpr$genotype, reorder = TRUE,
          chartOpts = list(corcolors = heat.colors(3),
                           scatcolors = c('#ff0000','#00ff0000','#0000ff')))

black
I've been using something like this to remove the alpha

rm_alpha <- function(x) {
  ## example
  # rm_alpha(c('#000000ff', 'red', '#nohexcol'))
  if (is.null(x)) NULL else gsub('(^#[A-Fa-f0-9]{6})[A-Fa-f0-9]{2}$', '\\1', x)
}

Or something easier to check all the chartOpts at once right at the end

rm_alpha_chartOpts <- function(co) {
  ## example
  # co <- list(pointcolor = NULL, rectcolor = '#f7f7f7', scatcolor = 'red',
  #            width = 700, height = 500)
  # rm_alpha_chartOpts(co)
  co[] <- lapply(seq_along(co), function(x)
    if (grepl('color', names(co[x]))) rm_alpha(co[[x]]) else co[[x]])
  co
}

And now the colors render (although without the transparency)

iplotCorr(geneExpr$expr, geneExpr$genotype, reorder = TRUE,
          chartOpts = rm_alpha_chartOpts(list(
                        corcolors = heat.colors(3),
                        scatcolors = c('#ff0000','#00ff0000','#0000ff'))))

color
Or just not using them would be another solution :}

Edit, now that I think about it, svg doesn't support alpha transparency, correct?

@kbroman
Copy link
Owner

kbroman commented Jul 15, 2015

SVG does support alpha transparency, but not via the color hex codes. One needs to use a separate "opacity" attribute.

I'll need to implement a separate chart option if you want the points in the scatterplot to be less-than-fully opaque.

(If the browser doesn't understand the color code, it just makes it black.)

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

No branches or pull requests

2 participants