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

flier objects missing from structure return by boxplot #3544

Closed
epipping opened this issue Sep 20, 2014 · 8 comments · Fixed by #3600
Closed

flier objects missing from structure return by boxplot #3544

epipping opened this issue Sep 20, 2014 · 8 comments · Fixed by #3600
Milestone

Comments

@epipping
Copy link
Contributor

The code

import matplotlib.pyplot as plt

def makeItGreen(boxpl):
  for key in boxpl:
    for obj in boxpl[key]:
      plt.setp(obj, color="green")

plt.clf()
x = [0.15, 0.11, 0.06, 0.06, 0.12, 0.56]
bp = plt.boxplot(x, sym="o")
makeItGreen(bp)

plt.show()

should create a boxplot with an outliner and then color everything green. This works as expected with matplotlib 1.3.1. With 1.4.0, the outlier does not change its color but remains blue. In 1.3.1, boxplot() returned a structure whose "fliers" field contained two objects; now there is just one.

@tacaswell
Copy link
Member

@phobson any progress on this?

@phobson
Copy link
Member

phobson commented Sep 30, 2014

@tacaswell Diagnostically, yes.

MPL 1.3 returned objects for two flier objects: the upper and lower fliers. I merged those objects together. We can split them back up, but that's not the cause of their properties not being set.

See this matploltib 1.3 notebook where everything works as expected.

Then a corresponding matploltib 1.4 notebook. In both cases, bp['fliers'] are Line2D objects. However, in matplotlob 1.4, you have to set_markerfacecolor, not simply set_color.

So I see a couple of possible issues:

  • there is something different about the new boxplot's doplot inner function that is calling/returning slightly different objects; or
  • something about Line2D objects changed -- namely, set_color now only applies to the color of a the line in v1.4 and not the line and the markers like it did in version 1.3.

@tacaswell
Copy link
Member

I am inclined to not split them back up (unless a boxplot expert tells me that setting the upper and lower fliers to be different colors is a thing.

@TomAugspurger Looks like we had an undocumented API change and the number of artist should be reduced.

The issues with the colors is that Line2D objects have some internal logic that allows the markerfacecolor and markeredgecolor to take precedence over color (the mechanism is that the marker* colors default to 'auto' which gets intercepted and replaced by the value for color in the function _get_marker_facecolor). I think the way to fix this to in the parsing of sym (now in boxplot) to delete setting the markerface and edge colors and do the same with the default flier dict.

@TomAugspurger
Copy link
Contributor

👍 Thanks. I'll adjust our test.

If this happens in the future I'll try to point them out more quickly. I'm usually somewhat up to date with mpl master and the pandas test suite give you all some extra coverage. This time I noticed the failure and just kept putting off investigating it :)

@phobson
Copy link
Member

phobson commented Sep 30, 2014

No, I'm sorry @TomAugspurger and @tacaswell. When I was creating the bxp function and refactoring boxplot to use it, I thought, "oh two if statements and plotting calls that very easily could be one" and didn't consider the downstream implications of that. Lots of lessons learned here, for me.

@phobson
Copy link
Member

phobson commented Sep 30, 2014

@tacaswell do you mean e.g., here and here

@tacaswell
Copy link
Member

@tacaswell
Copy link
Member

closed by #3600

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