Parallel coordinates plotting. To show a set of points in an n-dimensional space, a backdrop is drawn consisting of n parallel lines. A point in n-dimensional space is represented as a polyline with vertices on the parallel axes; the position of the vertex on the i-th axis corr
(
data,
class_column,
cols=None,
alpha=0.5,
width=600,
height=300,
var_name='variable',
value_name='value',
cmap=None,
colormap=None,
**kwds,
)
| 7 | |
| 8 | @with_hv_extension |
| 9 | def parallel_coordinates( |
| 10 | data, |
| 11 | class_column, |
| 12 | cols=None, |
| 13 | alpha=0.5, |
| 14 | width=600, |
| 15 | height=300, |
| 16 | var_name='variable', |
| 17 | value_name='value', |
| 18 | cmap=None, |
| 19 | colormap=None, |
| 20 | **kwds, |
| 21 | ): |
| 22 | """ |
| 23 | Parallel coordinates plotting. |
| 24 | |
| 25 | To show a set of points in an n-dimensional space, a backdrop is drawn |
| 26 | consisting of n parallel lines. A point in n-dimensional space is |
| 27 | represented as a polyline with vertices on the parallel axes; the |
| 28 | position of the vertex on the i-th axis corresponds to the i-th coordinate |
| 29 | of the point. |
| 30 | |
| 31 | Parameters |
| 32 | ---------- |
| 33 | frame : DataFrame |
| 34 | The DataFrame to be plotted. |
| 35 | class_column : str |
| 36 | Column name containing class names |
| 37 | cols : list, optional |
| 38 | A list of column names to use |
| 39 | alpha : float, optional |
| 40 | The transparency of the lines. Default is 0.5. |
| 41 | cmap/colormap : str or colormap object, optional |
| 42 | Colormap to use for groups. Default to Colorcet's ``glasbey_category10``. |
| 43 | |
| 44 | Returns |
| 45 | ------- |
| 46 | obj : HoloViews object |
| 47 | The HoloViews representation of the plot. |
| 48 | |
| 49 | See Also |
| 50 | -------- |
| 51 | pandas.plotting.parallel_coordinates : matplotlib version of this routine |
| 52 | """ |
| 53 | # Transform the dataframe to be used in Vega-Lite |
| 54 | if cols is not None: |
| 55 | data = data[list(cols) + [class_column]] |
| 56 | cols = data.columns |
| 57 | df = data.reset_index() |
| 58 | index = (set(df.columns) - set(cols)).pop() |
| 59 | assert index in df.columns |
| 60 | df = df.melt([index, class_column], var_name=var_name, value_name=value_name) |
| 61 | |
| 62 | labelled = [] if var_name == 'variable' else ['x'] |
| 63 | if value_name != 'value': |
| 64 | labelled.append('y') |
| 65 | options = { |
| 66 | 'Curve': dict(kwds, labelled=labelled, alpha=alpha, width=width, height=height), |
nothing calls this directly
no test coverage detected
searching dependent graphs…