Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Subsequent calls to plt.scatter with different categories raise ValueError #9700

Copy link
Copy link
Closed
@Bernhard10

Description

@Bernhard10
Issue body actions

Bug report

Plotting with string categorical data fails, if the second call to plt.scatter contains categories not present in the first call to plt.scatter
Code for reproduction

import matplotlib.pyplot as plt
plt.scatter(["a", "b"], [0,2])
plt.scatter(["a","c"], [1,4])

Actual outcome

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "xxx/python3.6/site-packages/matplotlib/pyplot.py", line 3357, in scatter
    edgecolors=edgecolors, data=data, **kwargs)
  File "xxx/python3.6/site-packages/matplotlib/__init__.py", line 1710, in inner
    return func(ax, *args, **kwargs)
  File "xxx/python3.6/site-packages/matplotlib/axes/_axes.py", line 4010, in scatter
    x = self.convert_xunits(x)
  File "xxx/python3.6/site-packages/matplotlib/artist.py", line 191, in convert_xunits
    return ax.xaxis.convert_units(x)
  File "xxx/python3.6/site-packages/matplotlib/axis.py", line 1491, in convert_units
    ret = self.converter.convert(x, self.units, self)
  File "xxx/python3.6/site-packages/matplotlib/category.py", line 53, in convert
    return vals.astype('float')
ValueError: could not convert string to float: 'c'

Expected outcome

figure_1

Figure generated using

plt.plot(["a", "b"], [0,2], "o")
plt.plot(["a", "c"], [1,4], "o")

Using different categories for subsequent calls to plt.plot works as expected.

Matplotlib version

  • Operating system: Fedora
  • Matplotlib version: 2.1.0 (installed the manylinux binary wheel via pip)
  • Matplotlib backend: TkAgg
  • Python version: 3.6.2

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.