Skip to content

BUG: fix handling of color argument for variety of plotting functions #6956

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 2 commits into from
May 5, 2014
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
12 changes: 12 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ Deprecations
returned if possible, otherwise a copy will be made. Previously the user could think that ``copy=False`` would
ALWAYS return a view. (:issue:`6894`)

- The :func:`parallel_coordinates` function now takes argument ``color``
instead of ``colors``. A ``FutureWarning`` is raised to alert that
the old ``colors`` argument will not be supported in a future release

- The :func:`parallel_coordinates` and :func:`andrews_curves` functions now take
positional argument ``frame`` instead of ``data``. A ``FutureWarning`` is
raised if the old ``data`` argument is used by name.

Prior Version Deprecations/Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -460,6 +468,10 @@ Bug Fixes
- Bug in timeseries-with-frequency plot cursor display (:issue:`5453`)
- Bug surfaced in groupby.plot when using a ``Float64Index`` (:issue:`7025`)
- Stopped tests from failing if options data isn't able to be downloaded from Yahoo (:issue:`7034`)
- Bug in ``parallel_coordinates`` and ``radviz`` where reordering of class column
caused possible color/class mismatch
- Bug in ``radviz`` and ``andrews_curves`` where multiple values of 'color'
were being passed to plotting method

pandas 0.13.1
-------------
Expand Down
8 changes: 8 additions & 0 deletions doc/source/v0.14.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,14 @@ Plotting

Because of the default `align` value changes, coordinates of bar plots are now located on integer values (0.0, 1.0, 2.0 ...). This is intended to make bar plot be located on the same coodinates as line plot. However, bar plot may differs unexpectedly when you manually adjust the bar location or drawing area, such as using `set_xlim`, `set_ylim`, etc. In this cases, please modify your script to meet with new coordinates.

- The :func:`parallel_coordinates` function now takes argument ``color``
instead of ``colors``. A ``FutureWarning`` is raised to alert that
the old ``colors`` argument will not be supported in a future release

- The :func:`parallel_coordinates` and :func:`andrews_curves` functions now take
positional argument ``frame`` instead of ``data``. A ``FutureWarning`` is
raised if the old ``data`` argument is used by name.

.. _whatsnew_0140.prior_deprecations:

Prior Version Deprecations/Changes
Expand Down
59 changes: 52 additions & 7 deletions pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,11 +1220,29 @@ def scat2(x, y, by=None, ax=None, figsize=None):
def test_andrews_curves(self):
from pandas import read_csv
from pandas.tools.plotting import andrews_curves

from matplotlib import cm

path = os.path.join(curpath(), 'data', 'iris.csv')
df = read_csv(path)

_check_plot_works(andrews_curves, df, 'Name')
_check_plot_works(andrews_curves, df, 'Name',
color=('#556270', '#4ECDC4', '#C7F464'))
_check_plot_works(andrews_curves, df, 'Name',
color=['dodgerblue', 'aquamarine', 'seagreen'])
_check_plot_works(andrews_curves, df, 'Name', colormap=cm.jet)

colors = ['b', 'g', 'r']
df = DataFrame({"A": [1, 2, 3],
"B": [1, 2, 3],
"C": [1, 2, 3],
"Name": colors})
ax = andrews_curves(df, 'Name', color=colors)
legend_colors = [l.get_color() for l in ax.legend().get_lines()]
self.assertEqual(colors, legend_colors)

with tm.assert_produces_warning(FutureWarning):
andrews_curves(data=df, class_column='Name')

@slow
def test_parallel_coordinates(self):
Expand All @@ -1235,20 +1253,31 @@ def test_parallel_coordinates(self):
df = read_csv(path)
_check_plot_works(parallel_coordinates, df, 'Name')
_check_plot_works(parallel_coordinates, df, 'Name',
colors=('#556270', '#4ECDC4', '#C7F464'))
_check_plot_works(parallel_coordinates, df, 'Name',
colors=['dodgerblue', 'aquamarine', 'seagreen'])
color=('#556270', '#4ECDC4', '#C7F464'))
_check_plot_works(parallel_coordinates, df, 'Name',
colors=('#556270', '#4ECDC4', '#C7F464'))
_check_plot_works(parallel_coordinates, df, 'Name',
colors=['dodgerblue', 'aquamarine', 'seagreen'])
color=['dodgerblue', 'aquamarine', 'seagreen'])
_check_plot_works(parallel_coordinates, df, 'Name', colormap=cm.jet)

df = read_csv(path, header=None, skiprows=1, names=[1, 2, 4, 8,
'Name'])
_check_plot_works(parallel_coordinates, df, 'Name', use_columns=True)
_check_plot_works(parallel_coordinates, df, 'Name',
xticks=[1, 5, 25, 125])

colors = ['b', 'g', 'r']
df = DataFrame({"A": [1, 2, 3],
"B": [1, 2, 3],
"C": [1, 2, 3],
"Name": colors})
ax = parallel_coordinates(df, 'Name', color=colors)
legend_colors = [l.get_color() for l in ax.legend().get_lines()]
self.assertEqual(colors, legend_colors)

with tm.assert_produces_warning(FutureWarning):
parallel_coordinates(df, 'Name', colors=colors)

with tm.assert_produces_warning(FutureWarning):
parallel_coordinates(data=df, class_column='Name')

@slow
def test_radviz(self):
Expand All @@ -1259,8 +1288,24 @@ def test_radviz(self):
path = os.path.join(curpath(), 'data', 'iris.csv')
df = read_csv(path)
_check_plot_works(radviz, df, 'Name')
_check_plot_works(radviz, df, 'Name',
color=('#556270', '#4ECDC4', '#C7F464'))
_check_plot_works(radviz, df, 'Name',
color=['dodgerblue', 'aquamarine', 'seagreen'])
_check_plot_works(radviz, df, 'Name', colormap=cm.jet)

colors = [[0., 0., 1., 1.],
[0., 0.5, 1., 1.],
[1., 0., 0., 1.]]
df = DataFrame({"A": [1, 2, 3],
"B": [2, 1, 3],
"C": [3, 2, 1],
"Name": ['b', 'g', 'r']})
ax = radviz(df, 'Name', color=colors)
legend_colors = [c.get_facecolor().squeeze().tolist()
for c in ax.collections]
self.assertEqual(colors, legend_colors)

@slow
def test_plot_int_columns(self):
df = DataFrame(randn(100, 4)).cumsum()
Expand Down
Loading