Skip to content

Commit 4ab5409

Browse files
author
Tom Augspurger
committed
Merge pull request #8513 from bjacobowski/parallel_coordinates-axvlines
ENH: axvlines - boolean option to parallel_coordinates plot
2 parents 1834541 + b9d2008 commit 4ab5409

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

doc/source/whatsnew/v0.15.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Enhancements
8181
- ``Series`` now works with map objects the same way as generators (:issue:`8909`).
8282
- Added context manager to ``HDFStore`` for automatic closing (:issue:`8791`).
8383
- ``to_datetime`` gains an ``exact`` keyword to allow for a format to not require an exact match for a provided format string (if its ``False). ``exact`` defaults to ``True`` (meaning that exact matching is still the default) (:issue:`8904`)
84+
- Added ``axvlines`` boolean option to parallel_coordinates plot function, determines whether vertical lines will be printed, default is True
8485

8586
.. _whatsnew_0152.performance:
8687

pandas/tests/test_graphics.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2354,7 +2354,9 @@ def test_parallel_coordinates(self):
23542354

23552355
df = self.iris
23562356

2357-
_check_plot_works(parallel_coordinates, df, 'Name')
2357+
ax = _check_plot_works(parallel_coordinates, df, 'Name')
2358+
nlines = len(ax.get_lines())
2359+
nxticks = len(ax.xaxis.get_ticklabels())
23582360

23592361
rgba = ('#556270', '#4ECDC4', '#C7F464')
23602362
ax = _check_plot_works(parallel_coordinates, df, 'Name', color=rgba)
@@ -2368,6 +2370,9 @@ def test_parallel_coordinates(self):
23682370
cmaps = lmap(cm.jet, np.linspace(0, 1, df['Name'].nunique()))
23692371
self._check_colors(ax.get_lines()[:10], linecolors=cmaps, mapping=df['Name'][:10])
23702372

2373+
ax = _check_plot_works(parallel_coordinates, df, 'Name', axvlines=False)
2374+
assert len(ax.get_lines()) == (nlines - nxticks)
2375+
23712376
colors = ['b', 'g', 'r']
23722377
df = DataFrame({"A": [1, 2, 3],
23732378
"B": [1, 2, 3],

pandas/tools/plotting.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds):
581581
@deprecate_kwarg(old_arg_name='data', new_arg_name='frame')
582582
def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None,
583583
use_columns=False, xticks=None, colormap=None,
584-
**kwds):
584+
axvlines=True, **kwds):
585585
"""Parallel coordinates plotting.
586586
587587
Parameters
@@ -601,6 +601,8 @@ def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None,
601601
A list of values to use for xticks
602602
colormap: str or matplotlib colormap, default None
603603
Colormap to use for line colors.
604+
axvlines: bool, optional
605+
If true, vertical lines will be added at each xtick
604606
kwds: keywords
605607
Options to pass to matplotlib plotting method
606608
@@ -665,8 +667,9 @@ def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None,
665667
else:
666668
ax.plot(x, y, color=colors[kls], **kwds)
667669

668-
for i in x:
669-
ax.axvline(i, linewidth=1, color='black')
670+
if axvlines:
671+
for i in x:
672+
ax.axvline(i, linewidth=1, color='black')
670673

671674
ax.set_xticks(x)
672675
ax.set_xticklabels(df.columns)

0 commit comments

Comments
 (0)