Skip to content

flier objects missing from structure return by boxplot #3544

Closed

Description

@epipping

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.

Activity

  1. added this to the v1.4.1 milestone on Sep 20, 2014
  2. tacaswell commented on Sep 30, 2014

    @tacaswell
    Member

    @phobson any progress on this?

  3. phobson commented on Sep 30, 2014

    @phobson
    Member

    @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.
  4. tacaswell commented on Sep 30, 2014

    @tacaswell
    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.

  5. TomAugspurger commented on Sep 30, 2014

    @TomAugspurger
    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 :)

  6. phobson commented on Sep 30, 2014

    @phobson
    Member

    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.

  7. phobson commented on Sep 30, 2014

    @phobson
    Member

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

  8. tacaswell commented on Oct 1, 2014

    @tacaswell
    Member

    closed by #3600

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions