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
scatter color
vs c
#7603
Comments
Can you reproduce this with out using pandas? Otherwise this probably should be reported against pandas. |
Can you also include the full traceback? |
This is the full trace: ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-f3d30057e124> in <module>()
14 columns=iris.feature_names)
15 scatterplot = pd.scatter_matrix(dataframe, alpha=0.3,
---> 16 figsize=(10, 10), diagonal='hist', color=colors, marker='o', grid=True)
/Users/e/anaconda/lib/python3.5/site-packages/pandas/tools/plotting.py in scatter_matrix(frame, alpha, figsize, ax, grid, diagonal, marker, density_kwds, hist_kwds, range_padding, **kwds)
393
394 ax.scatter(df[b][common], df[a][common],
--> 395 marker=marker, alpha=alpha, **kwds)
396
397 ax.set_xlim(boundaries_list[j])
/Users/e/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1817 warnings.warn(msg % (label_namer, func.__name__),
1818 RuntimeWarning, stacklevel=2)
-> 1819 return func(ax, *args, **kwargs)
1820 pre_doc = inner.__doc__
1821 if pre_doc is None:
/Users/e/anaconda/lib/python3.5/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
3787 facecolors = co
3788 if c is not None:
-> 3789 raise ValueError("Supply a 'c' kwarg or a 'color' kwarg"
3790 " but not both; they differ but"
3791 " their functionalities overlap.")
ValueError: Supply a 'c' kwarg or a 'color' kwarg but not both; they differ but their functionalities overlap. |
I tried with just matpltlib. As before Incidentally, I couldn't find anywhere the reference on the difference between import numpy as np
import matplotlib.pyplot as plt
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radiuses
plt.scatter(x, y, s=area, color=colors, alpha=0.5) This is the trace: ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/Users/e/anaconda/lib/python3.5/site-packages/matplotlib/colors.py in to_rgba(self, arg, alpha)
367 raise ValueError(
--> 368 'length of rgba sequence should be either 3 or 4')
369 else:
ValueError: length of rgba sequence should be either 3 or 4
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
/Users/e/anaconda/lib/python3.5/site-packages/matplotlib/colors.py in to_rgba_array(self, c, alpha)
398 # Single value? Put it in an array with a single row.
--> 399 return np.array([self.to_rgba(c, alpha)], dtype=np.float)
400 except ValueError:
/Users/e/anaconda/lib/python3.5/site-packages/matplotlib/colors.py in to_rgba(self, arg, alpha)
375 raise ValueError(
--> 376 'to_rgba: Invalid rgba arg "%s"\n%s' % (str(arg), exc))
377
ValueError: to_rgba: Invalid rgba arg "[ 0.51212644 0.22378055 0.06807402 0.43638562 0.68215248 0.1378158
0.15249078 0.55415346 0.47947919 0.12748865 0.72954419 0.37898197
0.42483739 0.1797149 0.59384571 0.54982906 0.05255149 0.4734899
0.90948923 0.08066408 0.22102738 0.77243848 0.05687152 0.38126391
0.05717766 0.3300619 0.81012634 0.60052149 0.46439006 0.86098937
0.93625576 0.16322075 0.14090725 0.88908521 0.32210086 0.55698194
0.18936879 0.7390388 0.03459946 0.85838907 0.22985901 0.15620236
0.58757227 0.96806694 0.58318205 0.00226799 0.00164644 0.2462151
0.9577508 0.57849709]"
length of rgba sequence should be either 3 or 4
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
/Users/e/anaconda/lib/python3.5/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
3777 try:
-> 3778 mcolors.colorConverter.to_rgba_array(co)
3779 except ValueError:
/Users/e/anaconda/lib/python3.5/site-packages/matplotlib/colors.py in to_rgba_array(self, c, alpha)
402 if c.ndim != 2 and c.dtype.kind not in 'SU':
--> 403 raise ValueError("Color array must be two-dimensional")
404 if (c.ndim == 2 and c.shape[1] == 4 and c.dtype.kind == 'f'):
ValueError: Color array must be two-dimensional
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-9-68c680282e55> in <module>()
9 area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radiuses
10
---> 11 plt.scatter(x, y, s=area, color=colors, alpha=0.5)
/Users/e/anaconda/lib/python3.5/site-packages/matplotlib/pyplot.py in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, hold, data, **kwargs)
3256 vmin=vmin, vmax=vmax, alpha=alpha,
3257 linewidths=linewidths, verts=verts,
-> 3258 edgecolors=edgecolors, data=data, **kwargs)
3259 finally:
3260 ax.hold(washold)
/Users/e/anaconda/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1817 warnings.warn(msg % (label_namer, func.__name__),
1818 RuntimeWarning, stacklevel=2)
-> 1819 return func(ax, *args, **kwargs)
1820 pre_doc = inner.__doc__
1821 if pre_doc is None:
/Users/e/anaconda/lib/python3.5/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
3778 mcolors.colorConverter.to_rgba_array(co)
3779 except ValueError:
-> 3780 raise ValueError("'color' kwarg must be an mpl color"
3781 " spec or sequence of color specs.\n"
3782 "For a sequence of values to be"
ValueError: 'color' kwarg must be an mpl color spec or sequence of color specs.
For a sequence of values to be color-mapped, use the 'c' kwarg instead.
|
That last exception message is telling you what the problem is, and how to fix it, so matplotlib is behaving as intended. I don't know what the problem is on the pandas side. |
It looks like a pandas issue. There is still a potential source of confusion in the matplotlib side. I guess many users will use |
@goyodiaz Thanks of the comment. I will also raise this error on pandas. |
Closed as not a matplotlib issue. |
This is working:
This is not working:
|
Did you try |
The following code gives error, but works replacing
color=
withc=
I suspect is either a bug, or some piece of documentation missing?
I'm using:
matplotlib 1.5.3
pandas 0.19.1
python 3.5
The text was updated successfully, but these errors were encountered: