@@ -13,6 +13,57 @@ def swatches(template=None):
13
13
14
14
swatches .__doc__ = _swatches .__doc__
15
15
16
+
17
+ def swatches_cyclical (template = None ):
18
+ """
19
+ Parameters
20
+ ----------
21
+ template : str or dict or plotly.graph_objects.layout.Template instance
22
+ The figure template name or definition.
23
+
24
+ Returns
25
+ -------
26
+ fig : graph_objects.Figure containing the displayed image
27
+ A `Figure` object. This figure demonstrates the color scales and
28
+ sequences in this module, as polar bar charts.
29
+ """
30
+ import plotly .graph_objects as go
31
+ from plotly .subplots import make_subplots
32
+ from plotly .express ._core import apply_default_cascade
33
+
34
+ args = dict (template = template )
35
+ apply_default_cascade (args )
36
+
37
+ rows = 2
38
+ cols = 4
39
+ scales = ["IceFire" , "Twilight" , "Edge" , "Phase" , "HSV" , "mrybm" , "mygbm" ]
40
+ fig = make_subplots (
41
+ rows = rows ,
42
+ cols = cols ,
43
+ subplot_titles = scales ,
44
+ specs = [[{"type" : "polar" }] * cols ] * rows ,
45
+ )
46
+
47
+ for i , scale in enumerate (scales ):
48
+ fig .add_trace (
49
+ go .Barpolar (
50
+ r = [1 ] * int (360 / 5 ),
51
+ theta = list (range (0 , 360 , 5 )),
52
+ marker_color = list (range (0 , 360 , 5 )),
53
+ marker_cmin = 0 ,
54
+ marker_cmax = 360 ,
55
+ marker_colorscale = scale ,
56
+ name = scale ,
57
+ ),
58
+ row = int (i / cols ) + 1 ,
59
+ col = i % cols + 1 ,
60
+ )
61
+ fig .update_traces (width = 5.2 , marker_line_width = 0 , base = 0.5 , showlegend = False )
62
+ fig .update_polars (angularaxis_visible = False , radialaxis_visible = False )
63
+ fig .update_layout (title = "plotly.colors.cyclical" , template = args ["template" ])
64
+ return fig
65
+
66
+
16
67
Twilight = [
17
68
"#e2d9e2" ,
18
69
"#9ebbc9" ,
@@ -131,6 +182,6 @@ def swatches(template=None):
131
182
# Prefix variable names with _ so that they will not be added to the swatches
132
183
_contents = dict (globals ())
133
184
for _k , _cols in _contents .items ():
134
- if _k .startswith ("_" ) or _k == "swatches" or _k .endswith ("_r" ):
185
+ if _k .startswith ("_" ) or _k . startswith ( "swatches" ) or _k .endswith ("_r" ):
135
186
continue
136
187
globals ()[_k + "_r" ] = _cols [::- 1 ]
0 commit comments