@@ -1532,6 +1532,8 @@ def named_colorscales(self):
15321532 and len (c ) == 2
15331533 and isinstance (c [0 ], str )
15341534 and isinstance (c [1 ], list )
1535+ and not c [0 ].endswith ("_r" )
1536+ and not c [0 ].startswith ("_" )
15351537 }
15361538
15371539 return self ._named_colorscales
@@ -1558,7 +1560,8 @@ def description(self):
15581560 and the second item is a valid color string.
15591561 (e.g. [[0, 'green'], [0.5, 'red'], [1.0, 'rgb(0, 0, 255)']])
15601562 - One of the following named colorscales:
1561- {colorscales_str}
1563+ {colorscales_str}.
1564+ Appending '_r' to a named colorscale reverses it.
15621565""" .format (
15631566 plotly_name = self .plotly_name , colorscales_str = colorscales_str
15641567 )
@@ -1575,13 +1578,16 @@ def validate_coerce(self, v):
15751578 if v_lower in self .named_colorscales :
15761579 # Convert to color list
15771580 v = self .named_colorscales [v_lower ]
1578-
1581+ v_valid = True
1582+ elif v_lower .endswith ("_r" ) and v_lower [:- 2 ] in self .named_colorscales :
1583+ v = self .named_colorscales [v_lower [:- 2 ]][::- 1 ]
1584+ v_valid = True
1585+ #
1586+ if v_valid :
15791587 # Convert to list of lists colorscale
15801588 d = len (v ) - 1
15811589 v = [[(1.0 * i ) / (1.0 * d ), x ] for i , x in enumerate (v )]
15821590
1583- v_valid = True
1584-
15851591 elif is_array (v ) and len (v ) > 0 :
15861592 # If firset element is a string, treat as colorsequence
15871593 if isinstance (v [0 ], string_types ):
0 commit comments