Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f2f2533

Browse filesBrowse files
committed
Updated with Andrew's PEP-8, efficiency comments for trisurf colorbar
1 parent 7baaf4e commit f2f2533
Copy full SHA for f2f2533

File tree

Expand file treeCollapse file tree

1 file changed

+14
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-9
lines changed

‎plotly/tools.py

Copy file name to clipboardExpand all lines: plotly/tools.py
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,27 +1491,32 @@ def _make_colorscale(colors, scale=None):
14911491
colorscale = []
14921492

14931493
if not scale:
1494-
for j in range(len(colors)):
1495-
colorscale.append([j * 1./(len(colors) - 1), colors[j]])
1494+
for j, color in enumerate(colors):
1495+
colorscale.append([j * 1./(len(colors) - 1), color])
14961496
return colorscale
14971497

14981498
else:
1499-
colorscale = [[scale[j], colors[j]] for j in range(len(colors))]
1499+
colorscale = [list(tup) for tup in zip(scale, colors)]
15001500
return colorscale
15011501

15021502
@staticmethod
15031503
def _convert_colorscale_to_rgb(colorscale):
15041504
"""
15051505
Converts the colors in a colorscale to rgb colors
1506+
1507+
A colorscale is an array of arrays, each with a numeric value as the
1508+
first item and a color as the second. This function specifically is
1509+
converting a colorscale with tuple colors (each coordinate between 0
1510+
and 1) into a colorscale with the colors transformed into rgb colors
15061511
"""
1507-
for index in range(len(colorscale)):
1508-
colorscale[index][1] = FigureFactory._convert_to_RGB_255(
1509-
colorscale[index][1]
1512+
for color in colorscale:
1513+
color[1] = FigureFactory._convert_to_RGB_255(
1514+
color[1]
15101515
)
15111516

1512-
for index in range(len(colorscale)):
1513-
colorscale[index][1] = FigureFactory._label_rgb(
1514-
colorscale[index][1]
1517+
for color in colorscale:
1518+
color[1] = FigureFactory._label_rgb(
1519+
color[1]
15151520
)
15161521
return colorscale
15171522

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.