Skip to content

Commit 6a6684f

Browse files
committed
Added support for passing xticks into parallel_plot()
1 parent df7f185 commit 6a6684f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pandas/tools/plotting.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds):
412412

413413

414414
def parallel_coordinates(data, class_column, cols=None, ax=None, colors=None,
415-
use_columns=False, **kwds):
415+
use_columns=False, xticks=None, **kwds):
416416
"""Parallel coordinates plotting.
417417
418418
Parameters:
@@ -423,6 +423,7 @@ def parallel_coordinates(data, class_column, cols=None, ax=None, colors=None,
423423
ax: matplotlib axis object, optional
424424
colors: A list or tuple of colors to use for the different classes, optional
425425
use_columns: If true, columns will be used as xticks, optional
426+
xticks: A list of values to use for xticks, optional
426427
kwds: A list of keywords for matplotlib plot method
427428
428429
Returns:
@@ -448,9 +449,17 @@ def random_color(column):
448449

449450
ncols = len(df.columns)
450451

451-
# Determine values to use for xticks
452-
if use_columns and np.all(np.isreal(list(df.columns))):
452+
# determine values to use for xticks
453+
if use_columns is True:
454+
if not np.all(np.isreal(list(df.columns))):
455+
raise ValueError('Columns must be numeric to be used as xticks')
453456
x = df.columns
457+
elif xticks is not None:
458+
if not np.all(np.isreal(xticks)):
459+
raise ValueError('xticks specified must be numeric')
460+
elif len(xticks) != ncols:
461+
raise ValueError('Length of xticks must match number of columns')
462+
x = xticks
454463
else:
455464
x = range(ncols)
456465

0 commit comments

Comments
 (0)