@@ -412,7 +412,7 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds):
412
412
413
413
414
414
def parallel_coordinates (data , class_column , cols = None , ax = None , colors = None ,
415
- ** kwds ):
415
+ use_columns = False , ** kwds ):
416
416
"""Parallel coordinates plotting.
417
417
418
418
Parameters:
@@ -422,6 +422,7 @@ def parallel_coordinates(data, class_column, cols=None, ax=None, colors=None,
422
422
cols: A list of column names to use, optional
423
423
ax: matplotlib axis object, optional
424
424
colors: A list or tuple of colors to use for the different classes, optional
425
+ use_columns: If true, columns will be used as xticks, optional
425
426
kwds: A list of keywords for matplotlib plot method
426
427
427
428
Returns:
@@ -446,7 +447,12 @@ def random_color(column):
446
447
used_legends = set ([])
447
448
448
449
ncols = len (df .columns )
449
- x = range (ncols )
450
+
451
+ # Determine values to use for xticks
452
+ if use_columns and np .all (np .isreal (list (df .columns ))):
453
+ x = df .columns
454
+ else :
455
+ x = range (ncols )
450
456
451
457
if ax == None :
452
458
ax = plt .gca ()
@@ -471,11 +477,12 @@ def random_color(column):
471
477
else :
472
478
ax .plot (x , y , color = colors [kls ], ** kwds )
473
479
474
- for i in range ( ncols ) :
480
+ for i in x :
475
481
ax .axvline (i , linewidth = 1 , color = 'black' )
476
482
477
483
ax .set_xticks (x )
478
484
ax .set_xticklabels (df .columns )
485
+ ax .set_xlim (x [0 ], x [- 1 ])
479
486
ax .legend (loc = 'upper right' )
480
487
ax .grid ()
481
488
return ax
0 commit comments