Opacity in Grouped Bar Charts with data.frame
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
When plotting a grouped bar chart with variable opacity with data in a data.frame, the opacity assigned to each column is not the one specified in the data.frame. In the example below, the 2 bars in group "A" are plotted with reduced opacity, as opposed to the 2 bars with colour "C". Strangely, if the data.frame is not ordered then it plots correctly.
library( plotly )
data = data.frame(
x = c( "A", "B", "A", "B" ),
y = c( 1, 2, 3, 4 ),
z = c( "C", "C", "D", "D" ),
opacity = c( 0.3, 0.3, 1, 1 )
)
# removing this lines the plot is correct
data = data[ order( data$x ),]
p = plot_ly(
data = data,
x = ~x,
y = ~y,
color = ~z,
marker = list( opacity = ~opacity ),
type = "bar" ) %>%
layout( barmode = "group" )
show( p )
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied R reproduction in plotly.R with the data frame both ordered and unordered. Trace the grouped bar chart handling of marker opacity and compare each bar's opacity with the data frame values. Done means ordering the data no longer changes which bars receive reduced opacity.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100