Skip to content

scatter() does not accept gray strings anymore #12429

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

Closed
gioelelm opened this issue Oct 7, 2018 · 2 comments · Fixed by #12431
Closed

scatter() does not accept gray strings anymore #12429

gioelelm opened this issue Oct 7, 2018 · 2 comments · Fixed by #12431
Labels
API: argument checking Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@gioelelm
Copy link

gioelelm commented Oct 7, 2018

Bug report

Bug summary

Passing a particula gray intensity as a string seems to be broken in matplotlib 3.0, at least for the scatter() function.
This kind of argument format should (and was) possible according to documentation.

Code for reproduction

plt.scatter(np.arange(10), np.arange(10), c="0.5")

Actual outcome

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-99-426550bf20a7> in <module>()
----> 1 plt.scatter(np.arange(10), np.arange(10), c="0.5")

~/anaconda3/lib/python3.6/site-packages/matplotlib/pyplot.py in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, data, **kwargs)
   2791         x=x, y=y, s=s, c=c, marker=marker, cmap=cmap, norm=norm,
   2792         vmin=vmin, vmax=vmax, alpha=alpha, linewidths=linewidths,
-> 2793         verts=verts, edgecolors=edgecolors, data=data, **kwargs)
   2794     sci(__ret)
   2795     return __ret

~/anaconda3/lib/python3.6/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
   1783                         "the Matplotlib list!)" % (label_namer, func.__name__),
   1784                         RuntimeWarning, stacklevel=2)
-> 1785             return func(ax, *args, **kwargs)
   1786 
   1787         inner.__doc__ = _add_data_doc(inner.__doc__,

~/anaconda3/lib/python3.6/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
   4187             try:  # First, does 'c' look suitable for value-mapping?
   4188                 c_array = np.asanyarray(c, dtype=float)
-> 4189                 n_elem = c_array.shape[0]
   4190                 if c_array.shape in xy_shape:
   4191                     c = np.ma.ravel(c_array)

IndexError: tuple index out of range

Expected outcome
same as:

plt.scatter(np.arange(10), np.arange(10), c=(0.5,0.5,0.5))

Matplotlib version

  • Operating system: Linux
  • Matplotlib version: 3.0
  • Matplotlib backend (print(matplotlib.get_backend())): notebook/inline
  • Python version: 3.6 (conda, default)
@jklymak
Copy link
Member

jklymak commented Oct 7, 2018

Confirmed in master and also for

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()
ax.scatter(np.arange(10), np.arange(10), c="0.5")
plt.show()

bisects to b1cd0a3 (#11383)

@jklymak
Copy link
Member

jklymak commented Oct 7, 2018

ping @afvincent looks like #11383 missed a case?

@jklymak jklymak added this to the v3.0.x milestone Oct 7, 2018
@jklymak jklymak added Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. API: argument checking labels Oct 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: argument checking Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants