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

boxplot in version 1.4.0 does not respect property settings for fliers (flierprops) #3459

Closed
salspaugh opened this issue Sep 3, 2014 · 15 comments
Labels
API: consistency Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@salspaugh
Copy link

Minimum amount of code to reproduce the bug:

import matplotlib.pyplot as plt

x = [0.15, 0.11, 0.06, 0.06, 0.12, 0.56]
flierprops = dict(marker='o', markerfacecolor='green', markersize=12, linestyle='none')
plt.boxplot(x, flierprops=flierprops)
plt.show()

This produces
buggy-boxplot

Note the flier is a large blue plus sign, not a green circle as specified by flierprops.

This happens with Python 2.7.8 and matplotlib 1.4.0 -- haven't tested other situations.

This bug does not seem to be dependent upon the particular choice of flierprops but I haven't exhaustively tested this.

Notably, this broken example can also be found in the boxplot demo code: http://matplotlib.org/examples/statistics/boxplot_demo.html

The relevant code at that page is shown in the third line at the top and the last two lines at the bottom of this image:

boxplot-demo-code

And the demo graph that results from this demo code is also broken in the same way as the first example -- a large blue plus is shown instead of the specified symbol:

boxplot-demo-broken-result

Lastly, note that if the the sym argument is provided that specifies the symbol desired, boxplot does seem to respect flierprops. Code example:

import matplotlib.pyplot as plt

x = [0.15, 0.11, 0.06, 0.06, 0.12, 0.56]
flierprops = dict(marker='o', markerfacecolor='red', markersize=16, linestyle='none')
plt.boxplot(x, flierprops=flierprops, sym='o') # Added sym argument!
plt.show()

Result:
buggy-boxplot-fix

If this is the intended fix or correct way to use this function, this should be made clear in the documentation and in the demo code.

Justification for this issue: There were closed issues related to this, but one seemed to involve some debate about defaults and the other seemed to concern only lower values. The bug reported here is not a problem with defaults nor just with lower fliers. Couldn't find other potential duplicates but apologies if that is the case.

@tacaswell tacaswell added this to the v1.4.x milestone Sep 3, 2014
@tacaswell
Copy link
Member

Thanks for the detailed bug report!

cc @phobson

@tacaswell tacaswell modified the milestones: v1.4.x, v1.4.1 Sep 3, 2014
@jimmyc42
Copy link

jimmyc42 commented Sep 3, 2014

I received a syntax error for trying to use capprops and whiskerprops keywords. There is a difference in the documentation as well (the title disagrees with the call signature).

@tacaswell
Copy link
Member

@jimmyc42 can you give us an example of the code that fails?

@jimmyc42
Copy link

jimmyc42 commented Sep 3, 2014

Here is the error message I got for whiskerprops which is similar to what capprops returns...


TypeError Traceback (most recent call last)
in ()
16
17 ga = boxplot(np.nan_to_num(fss[ij,:]),notch=True, positions=range(1,20,3),bootstrap=10000, patch_artist=True,boxprops = boxp,
---> 18 medianprops=mprops, flierprops = wprops, whiskerprops=wprops)
19 gb = boxplot(np.nan_to_num(fss[ik,:]),notch=True, positions=range(2,21,3),bootstrap=10000, patch_artist=True,boxprops = boxp,
20 medianprops=mprops, flierprops = wprops)

TypeError: boxplot() got an unexpected keyword argument 'whiskerprops'

@tacaswell
Copy link
Member

This is the result of some poor default values. sym takes precedence over flierprops and sym defaults to 'b+'.

As a work-around pass sym=None as a kwarg. I have a patch on the way.

@epipping
Copy link
Contributor

@tacaswell Unfortunately, your workaround does not seem to work for me. Here's what I'm doing (based on the above):

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

Two things should happen: The shape of the fliers should be a circle and absolutely everything should be green. I do get a circle but it's blue, while the rest is green. In matplotlib 1.3.1, instead, everything is green.

On a sidenote, the object bp["fliers"] contained 2 subobjects in version 1.3.1 of matplotlib and now only contains 1. Is this intentional?

@tacaswell
Copy link
Member

@Pipping That looks like an entirely different issue.

This issue has to do with boxplot/bxp having defaults that over-rode user supplied flierprops dictionaries.

Your issue has to do with the data structure returned apparently not containing the flier objects. Can you please make a new issue?

Also, I would advise against using object as a variable name as it shadows the built in object which may lead to really strange bugs.

Also also, why are you resetting the colors like this instead of controlling them via the arguements to boxplot?

@epipping
Copy link
Contributor

@tacaswell: In a manner similar to http://stackoverflow.com/a/16598291/179927 I plot two boxplots at once and then color both independently. I believe I cannot do this through the dictionaries which can be passed to boxplot().

Update: Since you object to object, object is now obj ;)

@tacaswell
Copy link
Member

Fair enough. That is probably something we should make easy, but I am not sure going with dict or list of dicts for each input is completely clever.

@epipping
Copy link
Contributor

So that would be #3544 now.

@tacaswell
Copy link
Member

Thank you
On Sep 19, 2014 8:22 PM, "pipping" notifications@github.com wrote:

So that would be #3544
#3544 now.


Reply to this email directly or view it on GitHub
#3459 (comment)
.

@phobson
Copy link
Member

phobson commented Sep 29, 2014

I'll look into this tonight. I think I figured out the issue with the code. --
Paul Hobson
Sorry if this is unintelligible. I'm on my phone.

On Wed, Sep 3, 2014 at 2:45 AM, Thomas A Caswell notifications@github.com
wrote:

Thanks for the detailed bug report!

cc @phobson

Reply to this email directly or view it on GitHub:
#3459 (comment)

@tacaswell
Copy link
Member

@phobson Which this? The fiierprops (which I think should be fixed) or the un-returned flier object?

@phobson
Copy link
Member

phobson commented Sep 29, 2014

I'm a bit behind. I was going to look at everything and figure out what needed to be done and try to do it. If the symbol issues are worked out, then I'll focus on the unreturned fliers. --
Paul Hobson
Sorry if this is unintelligible. I'm on my phone.

On Mon, Sep 29, 2014 at 12:22 PM, Thomas A Caswell
notifications@github.com wrote:

@phobson Which this? The fiierprops (which I think should be fixed) or the un-returned flier object?

Reply to this email directly or view it on GitHub:
#3459 (comment)

@tacaswell
Copy link
Member

closed by #3533

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: consistency Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

No branches or pull requests

5 participants