Skip to content

Commit 29ea770

Browse files
committed
More intermediate work
1 parent 9d8c909 commit 29ea770

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

plotly/tools.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
'Blackbody': ['rgb(0,0,0)', 'rgb(160,200,255)'],
4747
'Earth': ['rgb(0,0,130)', 'rgb(255,255,255)'],
4848
'Electric': ['rgb(0,0,0)', 'rgb(255,250,220)'],
49-
'Viridis': ['rgb(68,1,84)', 'rgb(253,231,37)']}
49+
'Viridis': 'Viridis'}
50+
#['rgb(68,1,84)', 'rgb(253,231,37)']}
5051

5152
# color constants for violin plot
5253
DEFAULT_FILLCOLOR = '#1f77b4'
@@ -1476,6 +1477,21 @@ class FigureFactory(object):
14761477
more information and examples of a specific chart type.
14771478
"""
14781479

1480+
@staticmethod
1481+
def _make_colorscale(colors):
1482+
"""
1483+
Makes a list of colors into a colorscale-acceptable form
1484+
1485+
For documentation regarding to the form of the output, see
1486+
https://plot.ly/python/reference/#mesh3d-colorscale
1487+
"""
1488+
colorscale = []
1489+
diff = 1./(len(colors) - 1)
1490+
1491+
for j in range(len(colors)):
1492+
colorscale.append([j * diff, colors[j]])
1493+
return colorscale
1494+
14791495
@staticmethod
14801496
def _validate_gantt(df):
14811497
"""
@@ -3134,16 +3150,21 @@ def _trisurf(x, y, z, simplices, colormap=None, color_func=None,
31343150
ii, jj, kk = simplices.T
31353151

31363152
# Adding intensity to Mesh3D Data
3137-
intensity = [j for j in range(len(x))]
3153+
intensity = [0]
3154+
3155+
div = 1./(len(x) - 1)
3156+
3157+
for j in range(1, len(x)+1):
3158+
intensity.append(j * div)
3159+
#print intensity
3160+
#intensity = [0 for j in range(len(x))]
31383161

3139-
colorscale_numbered = FigureFactory._make
3162+
colorscale_numbered = FigureFactory._make_colorscale(colormap)
31403163

31413164
triangles = graph_objs.Mesh3d(x=x, y=y, z=z, facecolor=facecolor,
31423165
i=ii, j=jj, k=kk, name='',
31433166
intensity=intensity,
3144-
colorscale=[[0, 'rgb(255, 0, 0)'],
3145-
[0.5, 'rgb(0, 255, 0)'],
3146-
[1, 'rgb(0, 0, 255)']],
3167+
colorscale=colorscale_numbered,
31473168
showscale=True)
31483169

31493170
if plot_edges is not True: # the triangle sides are not plotted

0 commit comments

Comments
 (0)