|
22 | 22 |
|
23 | 23 | frompandas.core.dtypes.commonimportis_list_like
|
24 | 24 |
|
25 |
| -importpandas.core.commonascom |
26 |
| - |
27 | 25 | ifTYPE_CHECKING:
|
28 | 26 | frommatplotlib.colorsimportColormap
|
29 | 27 |
|
@@ -251,31 +249,17 @@ def _is_floats_color(color: Color | Collection[Color]) -> bool:
|
251 | 249 | def_get_colors_from_color_type(color_type:str,num_colors:int)->list[Color]:
|
252 | 250 | """Get colors from user input color type."""
|
253 | 251 | ifcolor_type=="default":
|
254 |
| -return_get_default_colors(num_colors) |
| 252 | +prop_cycle=mpl.rcParams["axes.prop_cycle"] |
| 253 | +return [ |
| 254 | +c["color"] |
| 255 | +forcinitertools.islice(prop_cycle,min(num_colors,len(prop_cycle))) |
| 256 | + ] |
255 | 257 | elifcolor_type=="random":
|
256 |
| -return_get_random_colors(num_colors) |
| 258 | +returnnp.random.default_rng(num_colors).random((num_colors,3)).tolist() |
257 | 259 | else:
|
258 | 260 | raiseValueError("color_type must be either 'default' or 'random'")
|
259 | 261 |
|
260 | 262 |
|
261 |
| -def_get_default_colors(num_colors:int)->list[Color]: |
262 |
| -"""Get `num_colors` of default colors from matplotlib rc params.""" |
263 |
| -colors= [c["color"]forcinmpl.rcParams["axes.prop_cycle"]] |
264 |
| -returncolors[0:num_colors] |
265 |
| - |
266 |
| - |
267 |
| -def_get_random_colors(num_colors:int)->list[Color]: |
268 |
| -"""Get `num_colors` of random colors.""" |
269 |
| -return [_random_color(num)fornuminrange(num_colors)] |
270 |
| - |
271 |
| - |
272 |
| -def_random_color(column:int)->list[float]: |
273 |
| -"""Get a random color represented as a list of length 3""" |
274 |
| -# GH17525 use common._random_state to avoid resetting the seed |
275 |
| -rs=com.random_state(column) |
276 |
| -returnrs.rand(3).tolist() |
277 |
| - |
278 |
| - |
279 | 263 | def_is_single_string_color(color:Color)->bool:
|
280 | 264 | """Check if `color` is a single string color.
|
281 | 265 |
|
|