Skip to content

Are categorical plots with single letter strings limited to show 10 categories? #9843

Closed

Description

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()

image

In case at least one of the categories has more letters, x.append("WORD"), the plot is shown correctly:

image

(This issue was brouht up in this Stackoverflow question)
[Produced with python 2.7, matplotlib 2.1, numpy 1.13.0rc2]

Activity

  1. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Nov 24, 2017
  2. anntzer commented on Nov 24, 2017

    @anntzer
    Contributor

    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.

  3. added this to the v2.1.1 milestone on Nov 25, 2017
  4. story645 commented on Nov 28, 2017

    @story645
    Member

    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.)

    mcat.StrCategoryConverter.convert(ax.xaxis.unit_data.seq, None, ax.xaxis)

    yields

    array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.,  1.])
    
  5. added a commit that references this issue on Nov 29, 2017
  6. modified the milestones: v2.1.1, on Dec 6, 2017
  7. tacaswell commented on Feb 12, 2018

    @tacaswell
    Member

    Closed by #9783

  8. modified the milestones: , v2.2.0 on Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: categorical

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions