plotly / plotly/plotly.R

Opacity/alpha as attribute linked to a continuous variable

Open
#1,663 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

I am trying to get a continuous transparency according to a continuous variable that also defines the color. I've tried the code suggested in this post https://github.com/ropensci/plotly/issues/389 but I dont manage to do what I want and, in fact, I get very unexpected plots since the colorbar and marker's colors do not match + transparency seems the same for all colors.

require(plotly)
plot_ly(x = rnorm(100), y = rnorm(100), z = rnorm(100),
color = rbeta(100,shape1=1,shape2=1),alpha=.2,
type = "scatter3d", mode= "markers",
colors=colorRamp(c("blue","red")))

I'd like to get low transparency at high color values and vice versa. Is this possible in the currrent version of plot_ly?

plot_ly(x = rnorm(100), y = rnorm(100), z = rnorm(100),
color = rbeta(100,shape1=1,shape2=1),opacity=.2,
type = "scatter3d", mode= "markers",
colors=colorRamp(c("blue","red")))

setting opacity instead of alpha seems to fix the colouring vs colorbar but not the transparency issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducible plot_ly scatter3d examples in the issue and investigate how color, alpha, and opacity are mapped for markers. Verify the behavior against the colorbar and marker appearance; done means a continuous variable can control both color and transparency as requested, without mismatched colors.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.