Skip to content

Commit 9a70e9e

Browse files
committed
cycle_wrapper bugfix with colors in lists/ndarrays
1 parent 03c3b0f commit 9a70e9e

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

docs/1dplots.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@
8888
"axs.format(suptitle='Automatic subplot formatting')\n",
8989
"\n",
9090
"# Plot DataArray\n",
91-
"cycle = plot.Cycle(plot.shade('light blue', 0.4), fade=90, space='hpl')\n",
91+
"color = plot.shade('light blue', 0.4)\n",
92+
"cycle = plot.Cycle(color, fade=90, space='hpl')\n",
9293
"axs[0].plot(da, cycle=cycle, lw=3, colorbar='ul', colorbar_kw={'locator': 20})\n",
9394
"\n",
9495
"# Plot Dataframe\n",
95-
"cycle = plot.Cycle(plot.shade('jade', 0.4), fade=90, space='hpl')\n",
96+
"color = plot.shade('jade', 0.4)\n",
97+
"cycle = plot.Cycle(color, fade=90, space='hpl')\n",
9698
"axs[1].plot(df, cycle=cycle, lw=3, legend='uc')"
9799
]
98100
},

docs/2dplots.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@
9595
"axs[0].format(yreverse=True)\n",
9696
"\n",
9797
"# Plot DataFrame\n",
98-
"axs[1].contourf(df, cmap='Blues', colorbar='r', linewidth=0.7, color='gray7')\n",
98+
"axs[1].contourf(\n",
99+
" df, cmap='Blues', colorbar='r', linewidth=0.7, color='gray7'\n",
100+
")\n",
99101
"axs[1].format(xtickminor=False)"
100102
]
101103
},

proplot/styletools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,8 +2355,7 @@ def Cycle(
23552355
)
23562356
nprops = max(nprops, len(value))
23572357
props[key] = [*value] # ensure mutable list
2358-
# If args is non-empty, means we want color cycle; otherwise is always
2359-
# black
2358+
# If args is non-empty, means we want color cycle; otherwise is black
23602359
if not args:
23612360
props['color'] = ['k'] # ensures property cycler is non empty
23622361
if kwargs:
@@ -2416,8 +2415,9 @@ def Cycle(
24162415
# Build cycler, make sure lengths are the same
24172416
for key, value in props.items():
24182417
if len(value) < nprops:
2419-
value[:] = [value[i % len(value)] for i in range(
2420-
nprops)] # make loop double back
2418+
value[:] = [
2419+
value[i % len(value)] for i in range(nprops)
2420+
] # make loop double back
24212421
cycle = cycler.cycler(**props)
24222422
cycle.name = name
24232423
return cycle

proplot/wrappers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,8 @@ def cycle_changer(
15251525
for key, value in prop.items():
15261526
if key not in by_key:
15271527
by_key[key] = {*()} # set
1528+
if isinstance(value, (list, np.ndarray)):
1529+
value = tuple(value)
15281530
by_key[key].add(value)
15291531
# Reset property cycler if it differs
15301532
reset = ({*by_key} != {*cycle.by_key()}) # reset if keys are different

0 commit comments

Comments
 (0)