Here is an toy example. The opacity value in data.frame has no impact
library(plotly)
df <- data.frame(x=c(1,2),y=c(6,3),opacity=c(1,0.2))
plot_ly(df,
type="bar",
x=x,
y=y,
opacity=opacity,
marker = list(
color='#5a22e3'
)
)
I might also want to extend have a color column in df and utilize that in place of the fixed value above TIA
You can add a group
so that it knows to look for more than one opacity:
plot_ly(df,
type="bar",
x=x,
y=y,
group=x,
opacity=opacity,
marker = list(
color='#5a22e3'
)
)
Update
With respect to color, adding color
as a variable does a similar thing as group
, but it needs to be a factor or a character variable (note that I removed group
):
plot_ly(df,
type="bar",
x=x,
y=y,
opacity=opacity,
color=as.factor(x)
)
Since there are only two levels, this will give you a warning, so you can put all that into a suppressWarnings()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With