Skip to content
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

Str Categorical Axis Support #6689

Merged
merged 2 commits into from Jul 8, 2016
Merged

Conversation

story645
Copy link
Member

@story645 story645 commented Jul 5, 2016

Cleaned up and updated version of #6612, this adds support for directly plotting lists of strings, so that the following is now possible:

index

data = {'apples':10, 'oranges':15, 'lemons':5, 'limes':20}
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.bar(list(data.keys()), list(data.values()), align='center', color='lightgray')
ax.xaxis.set_tick_params(size=0)

index

cat = ["bored", "happy", "bored", "bored", "happy", "bored"]
dog = ["happy", "happy", "happy", "happy", "bored", "happy"]
time = ["combing", "drinking","feeding", "napping", "playing", "washing"]

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot(time, dog, label="dog")
ax.plot(time, cat, label="cat")
ax.legend()

Now fighting with the update ticks (@tacaswell) use case:

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(['a', 'b'])
ax.plot(['a', 'b', 'd'])
ax.plot(['b', 'c', 'd'])

'cause it breaks in randomly different ways without the other tests failing.

And beats my why, but Python2.7 triggers weirdness with the bounds & view_limits that Python3.5 doesn't:

_axes.py", line 4023, in scatter: self.autoscale_view()
/axes/_base.py", line 2283, in autoscale_view: margins['left'], margins['right'], self.set_xbound)
axes/_base.py", line 2278, in handle_single_axis: set_bound(x0, x1)
axes/_base.py", line 2763, in set_xbound: self.set_xlim(lower, upper, auto=None)
axes/_base.py", line 2830, in set_xlim: left = self.convert_xunits(left)
artist.py", line 197, in convert_xunits: return ax.xaxis.convert_units(x)
axis.py", line 1500, in convert_units: ret = self.converter.convert(x, self.units, self)
category.py", line 24, in convert: vals = vmap[value]
KeyError: -1.1049590217242939

this was 'caused by plt.plot('a')

@@ -21,7 +21,9 @@
import matplotlib.collections as mcoll
import matplotlib.colors as mcolors
import matplotlib.contour as mcontour
import matplotlib.category as _ # <-registers a date unit converter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in comment.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Jul 7, 2016
@tacaswell
Copy link
Member

Can you revert the merge of master into this branch?

@tacaswell
Copy link
Member

Ah, I see there are a bunch of them, I will see if I can de-tangle this.

… for updating ticks/animation in progress/buggy, 'especially for scatter.
@tacaswell
Copy link
Member

If you look at the category branch on my gh I have cherry-picked off all of your commits and rebased them onto current master.

The changes to the code are exactly the same, but the history is cleaner

22:15 $ git diff story645/category tacaswell/category

shows that there are no code changes.

I suggest you do the following

  • make a new branch on your current branch (just to be safe)
  • reset your local category branch to be my cleaned one git reset --hard tacaswell/category
  • push that branch to your gh git push --force

If you have not discovered magit (https://github.com/magit/magit) yet, I can not suggest it highly enough.

@tacaswell
Copy link
Member

appveyor failure is spurious (failed upload, tests passed).

@tacaswell tacaswell merged commit 5c1e64d into matplotlib:master Jul 8, 2016
@tacaswell
Copy link
Member

appveyor failure is spurious (failed upload, tests passed).

The plan is to collect a single what_new entry + examples towards the end.

@tacaswell
Copy link
Member

🎆 🎉 🎆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants