MCPcopy
hub / github.com/pandas-dev/pandas / parallel_coordinates

Function parallel_coordinates

pandas/plotting/_matplotlib/misc.py:345–423  ·  view source on GitHub ↗
(
    frame: DataFrame,
    class_column,
    cols=None,
    ax: Axes | None = None,
    color=None,
    use_columns: bool = False,
    xticks=None,
    colormap=None,
    axvlines: bool = True,
    axvlines_kwds=None,
    sort_labels: bool = False,
    **kwds,
)

Source from the content-addressed store, hash-verified

343
344
345def parallel_coordinates(
346 frame: DataFrame,
347 class_column,
348 cols=None,
349 ax: Axes | None = None,
350 color=None,
351 use_columns: bool = False,
352 xticks=None,
353 colormap=None,
354 axvlines: bool = True,
355 axvlines_kwds=None,
356 sort_labels: bool = False,
357 **kwds,
358) -> Axes:
359 import matplotlib.pyplot as plt
360
361 if axvlines_kwds is None:
362 axvlines_kwds = {"linewidth": 1, "color": "black"}
363
364 n = len(frame)
365 classes = frame[class_column].drop_duplicates()
366 class_col = frame[class_column]
367
368 if cols is None:
369 df = frame.drop(class_column, axis=1)
370 else:
371 df = frame[cols]
372
373 used_legends: set[str] = set()
374
375 ncols = len(df.columns)
376
377 # determine values to use for xticks
378 x: list[int] | Index
379 if use_columns is True:
380 if not np.all(np.isreal(list(df.columns))):
381 raise ValueError("Columns must be numeric to be used as xticks")
382 x = df.columns
383 elif xticks is not None:
384 if not np.all(np.isreal(xticks)):
385 raise ValueError("xticks specified must be numeric")
386 if len(xticks) != ncols:
387 raise ValueError("Length of xticks must match number of columns")
388 x = xticks
389 else:
390 x = list(range(ncols))
391
392 if ax is None:
393 ax = plt.gca()
394
395 color_values = get_standard_colors(
396 num_colors=len(classes), colormap=colormap, color_type="random", color=color
397 )
398
399 if sort_labels:
400 classes = sorted(classes)
401 color_values = sorted(color_values)
402 colors = dict(zip(classes, color_values, strict=True))

Callers

nothing calls this directly

Calls 7

get_standard_colorsFunction · 0.90
pprint_thingFunction · 0.90
drop_duplicatesMethod · 0.45
dropMethod · 0.45
allMethod · 0.45
addMethod · 0.45
plotMethod · 0.45

Tested by

no test coverage detected