Skip to content
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
6 changes: 6 additions & 0 deletions lib/matplotlib/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def convert(value, unit, axis):
"""Uses axis.unit_data map to encode
data as floats
"""
value = np.atleast_1d(value)
# try and update from here....
if hasattr(axis.unit_data, 'update'):
for val in value:
if isinstance(val, six.string_types):
axis.unit_data.update(val)
vmap = dict(zip(axis.unit_data.seq, axis.unit_data.locs))

if isinstance(value, six.string_types):
Expand Down
13 changes: 13 additions & 0 deletions lib/matplotlib/tests/test_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,16 @@ def test_plot_update(self):
unit_data = MockUnitData(list(zip(labels, ticks)))

self.axis_test(ax.yaxis, ticks, labels, unit_data)

def test_scatter_update(self):
fig, ax = plt.subplots()

ax.scatter(['a', 'b'], [0., 3.])
ax.scatter(['a', 'b', 'd'], [1., 2., 3.])
ax.scatter(['b', 'c', 'd'], [4., 1., 2.])
fig.canvas.draw()

labels = ['a', 'b', 'd', 'c']
ticks = [0, 1, 2, 3]
unit_data = MockUnitData(list(zip(labels, ticks)))
self.axis_test(ax.xaxis, ticks, labels, unit_data)