3d Surface bug in Python? A custom colorscale defined with rgba values ignores the alpha specification
See original GitHub issueHi There!
I am trying to create a surface with surfacecolor and a custom colorscale to set a per point transparency.
The global opacity is working well, however the per point opacity specified in a custom colorscale with the rga definitions are ignored.
This is what I am doing:
from skimage.draw import circle
import plotly.graph_objects as go
import pandas as pd
import numpy as np
%pylab inline
# Read data from a csv
z_data = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv')
#make a custom surfacecolor to color just the middle of the surface
surfacecolor = np.zeros((25, 25), dtype=np.uint8)
rr, cc = circle(12.5, 12.5, 5)
surfacecolor[rr, cc] = 1
plt.matshow(surfacecolor)
#simple colorscale from black to pure red
colorscale=[
[0, "rgb(0, 0, 0)"],
[1.0, "rgb(255, 0, 0)"]]
#Plotting a surface with the global opacity is working well!
fig = go.Figure(data=[go.Surface(z=z_data.values,opacity=0.8, surfacecolor=surfacecolor,colorscale=colorscale)])
fig.update_layout(title='Mt Bruno Elevation', autosize=False,
width=500, height=500,
margin=dict(l=65, r=50, b=65, t=90))
fig.show()
# Same as before but now we use rgba to set the transparency, black now should be full transparent
colorscale=[
[0, "rgba(0, 0, 0,0)"],
[1.0, "rgba(255, 0, 0,1)"]]
#per point opacity is broken :(
fig = go.Figure(data=[go.Surface(z=z_data.values,
surfacecolor=surfacecolor,
colorscale=colorscale)])
fig.update_layout(title='Mt Bruno Elevation', autosize=False,
width=500, height=500,
margin=dict(l=65, r=50, b=65, t=90))
fig.show()
#this is not working :(
I created a jupyter notebook so you can reproduce the error
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Latest 📊 Plotly Python topics
Topic Replies Views Activity
Creating custom tick labels in a plot 5 24457 November 7, 2019
Multiple traces sub plots with common trace names 12...
Read more >python - Plotly - different color surfaces
Sets the surface color values, used for setting a color scale ... But you can define your own color scale with the needed...
Read more >Color — Godot Engine (stable) documentation in English
A color represented by red, green, blue, and alpha (RGBA) components. The alpha component is often used for opacity. Values are in floating-point...
Read more >Specifying Colors — Matplotlib 3.1.0 documentation
Matplotlib recognizes the following formats to specify a color: an RGB or RGBA (red, green, blue, alpha) tuple of float values in [0,...
Read more >What's new — MNE 1.2.2 documentation
Fix bugs in documentation of surface SourceSpaces (#11171 by Eric Larson) ... Fix bug in mne.export.export_raw() to ignore None value in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can post a feature request on the plotly.js repo.
Yes, this makes perfect sense. Thank you so much @nicolaskruchten !