You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Are categorical plots with single letter strings limited to show 10 categories? #9843
It seems categorical plots are limited to show 10 categories correctly when single letters are used as categories. The eleventh category is shown at the place of the second one.
import matplotlib.pyplot as plt
x = list("ABCDEFGHIJK")
y = range(len(x))
plt.plot(x,y, marker="o")
plt.show()
In case at least one of the categories has more letters, x.append("WORD"), the plot is shown correctly:
(This issue was brouht up in this Stackoverflow question)
[Produced with python 2.7, matplotlib 2.1, numpy 1.13.0rc2]
I'd guess this is due to the current implementation of categorical mapping which casts indices to strings stored in the same array as the labels and back into numbers. If the array has dtype S1 (for example), i.e. string of width 1, then the labels get truncated.
There are various PRs around that rework categorical support, they should hopefully fix this issue as well.
I think you mean that the values get truncated, ie the 10 gets truncated to a 1 before it's cast back to an int. (The sequence and locs are stored correctly.)
Activity
anntzer commentedon Nov 24, 2017
I'd guess this is due to the current implementation of categorical mapping which casts indices to strings stored in the same array as the labels and back into numbers. If the array has dtype S1 (for example), i.e. string of width 1, then the labels get truncated.
There are various PRs around that rework categorical support, they should hopefully fix this issue as well.
story645 commentedon Nov 28, 2017
I think you mean that the values get truncated, ie the 10 gets truncated to a 1 before it's cast back to an int. (The sequence and locs are stored correctly.)
yields
added test for matplotlib#9843
added test for matplotlib#9843
added test for matplotlib#9843
added test for matplotlib#9843
added test for matplotlib#9843
tacaswell commentedon Feb 12, 2018
Closed by #9783