Skip to content

Commit 51d480d

Browse files
committed
Move constructor.Colors --> utils.get_colors
1 parent 5626bc8 commit 51d480d

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

proplot/constructor.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
_version_mpl,
3838
warnings,
3939
)
40-
from .utils import to_rgba
40+
from .utils import to_hex, to_rgba, get_colors
4141

4242
try:
4343
from mpl_toolkits.basemap import Basemap
@@ -336,20 +336,6 @@
336336
}
337337

338338

339-
def Colors(*args, **kwargs):
340-
"""
341-
Pass all arguments to `Cycle` and return the list of colors from
342-
the resulting `~cycler.Cycler` object.
343-
344-
See also
345-
--------
346-
cycler.Cycler
347-
Cycle
348-
"""
349-
cycle = Cycle(*args, **kwargs)
350-
return list(dict_['color'] for dict_ in cycle)
351-
352-
353339
def _modify_colormap(cmap, *, cut, left, right, reverse, shift, alpha, samples):
354340
"""
355341
Modify colormap using a variety of methods.
@@ -1523,3 +1509,9 @@ def Proj(name, basemap=None, **kwargs):
15231509
proj._proj_package = 'cartopy'
15241510

15251511
return proj
1512+
1513+
1514+
# Deprecated
1515+
Colors = warnings._rename_objs(
1516+
'0.8', Colors=get_colors
1517+
)

proplot/utils.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'arange',
1919
'edges',
2020
'edges2d',
21-
'units',
21+
'get_colors',
2222
'set_hue',
2323
'set_saturation',
2424
'set_luminance',
@@ -208,6 +208,33 @@ def edges2d(z):
208208
return zb
209209

210210

211+
def get_colors(*args, **kwargs):
212+
"""
213+
Get the colors associated with a registered or
214+
on-the-fly color cycle.
215+
216+
Parameters
217+
----------
218+
*args, **kwargs
219+
Passed to `~proplot.constructor.Cycle`.
220+
221+
Returns
222+
-------
223+
colors : list of str
224+
A list of HEX strings.
225+
226+
See also
227+
--------
228+
cycler.Cycler
229+
proplot.constructor.Cycle
230+
proplot.constructor.Colormap
231+
"""
232+
from .constructor import Cycle # delayed to avoid cyclic imports
233+
cycle = Cycle(*args, **kwargs)
234+
colors = [to_hex(dict_['color']) for dict_ in cycle]
235+
return colors
236+
237+
211238
def _transform_color(func, color, space):
212239
"""
213240
Standardize input for color transformation functions.

0 commit comments

Comments
 (0)