Skip to content

ENH: axvlines - boolean option to parallel_coordinates plot #8513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.15.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Enhancements
- ``Series`` now works with map objects the same way as generators (:issue:`8909`).
- Added context manager to ``HDFStore`` for automatic closing (:issue:`8791`).
- ``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`)
- Added ``axvlines`` boolean option to parallel_coordinates plot function, determines whether vertical lines will be printed, default is True

.. _whatsnew_0152.performance:

Expand Down
7 changes: 6 additions & 1 deletion pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,9 @@ def test_parallel_coordinates(self):

df = self.iris

_check_plot_works(parallel_coordinates, df, 'Name')
ax = _check_plot_works(parallel_coordinates, df, 'Name')
nlines = len(ax.get_lines())
nxticks = len(ax.xaxis.get_ticklabels())

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

ax = _check_plot_works(parallel_coordinates, df, 'Name', axvlines=False)
assert len(ax.get_lines()) == (nlines - nxticks)

colors = ['b', 'g', 'r']
df = DataFrame({"A": [1, 2, 3],
"B": [1, 2, 3],
Expand Down
9 changes: 6 additions & 3 deletions pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds):
@deprecate_kwarg(old_arg_name='data', new_arg_name='frame')
def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None,
use_columns=False, xticks=None, colormap=None,
**kwds):
axvlines=True, **kwds):
"""Parallel coordinates plotting.

Parameters
Expand All @@ -601,6 +601,8 @@ def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None,
A list of values to use for xticks
colormap: str or matplotlib colormap, default None
Colormap to use for line colors.
axvlines: bool, optional
If true, vertical lines will be added at each xtick
kwds: keywords
Options to pass to matplotlib plotting method

Expand Down Expand Up @@ -665,8 +667,9 @@ def parallel_coordinates(frame, class_column, cols=None, ax=None, color=None,
else:
ax.plot(x, y, color=colors[kls], **kwds)

for i in x:
ax.axvline(i, linewidth=1, color='black')
if axvlines:
for i in x:
ax.axvline(i, linewidth=1, color='black')

ax.set_xticks(x)
ax.set_xticklabels(df.columns)
Expand Down