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

Allow to set na.color transparent #47

Open
billy34 opened this issue May 4, 2020 · 1 comment
Open

Allow to set na.color transparent #47

billy34 opened this issue May 4, 2020 · 1 comment

Comments

@billy34
Copy link

billy34 commented May 4, 2020

It would be good to be able to set na.color to NA in order to not display NA values (be transparent)

I managed to do this be changing a single line in ScaleColorPlane.R (near line 72)

# prefill with the NA color so we can do the projection as an inset, process
# the NA color to ensure proper #xxxxxx form regardless of unput type
df[[aesthetics[1]]] <- grDevices::rgb(
  t(grDevices::col2rgb(self$na.color[1])),
  maxColorValue = 255)

to

# prefill with the NA color so we can do the projection as an inset, process
# the NA color to ensure proper #xxxxxx form regardless of unput type
df[[aesthetics[1]]] <- do.call(grDevices::rgb,
  c(as.list(grDevices::col2rgb(self$na.color[1],TRUE)),
  maxColorValue = 255))

I had to use do.call because rgb does not allow to provide an RGBA vector to the first parameter (only RGB)

@wmurphyrd
Copy link
Owner

Good find. Could you send a pr?

billy34 pushed a commit to billy34/colorplaner that referenced this issue May 4, 2020
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