Skip to content

axes.boxplot does not have zorder kwarg #7171

Closed

Description

@nancysendoh

Hi eveybody,

I want to draw boxplot and scatter in one figure, but the boxplot always covers the points as below:
1

How could I set the scatter above the boxplot? Thanks ~

Here's my code:

import matplotlib.pyplot as plt
import numpy as np

x=[1,2,3]
a=np.array([70,170,130])
y=[]
yy=[]
for i in range(3):
    yy.append(np.random.randn(5))
    y.append(yy[i].mean())

plt.figure()
fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(5, 5))
axes.scatter(x,y,c='r',s=a)
bplot1 = axes.boxplot(yy,
                     vert=True,   # vertical box aligmnent
                     patch_artist=True)   # fill with color
color = 'blue'
for patch in bplot1['boxes']:
    patch.set_facecolor(color)
    patch.set_alpha(0.5)
plt.savefig('1.jpg',dpi=100)
plt.show()

Activity

  1. changed the title [-]How to set the layer irder?[/-] [+]How to set the layer order?[/+] on Sep 24, 2016
  2. Phlya commented on Sep 24, 2016

    @Phlya
    Contributor

    Use zorder argument in plotting commands, the higher the value, the more on top will be the objects.

  3. Kojoley commented on Sep 24, 2016

    @Kojoley
    Member

    Please do not use the issue tracker to ask questions, use mailing list or gitter for this. https://github.com/matplotlib/matplotlib#contact

  4. nancysendoh commented on Sep 24, 2016

    @nancysendoh
    Author

    thanks a lot! it's very helpful. but it seems the boxplot() doesn't have the zorder argument. So I couldn't set the order of two boxplot?
    thanks again!

    发自我的小米手机
    在 Ilya Flyamer notifications@github.com,2016年9月24日 下午3:53写道:

    Use zorder argument in plotting commands, the higher the value, the more on top will be the objects.

    —
    You are receiving this because you authored the thread.
    Reply to this email directly, view it on GitHubhttps://github.com//issues/7171#issuecomment-249351562, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJwUtAK2JH3QhwFaExArarpu4LXbYtdPks5qtNcNgaJpZM4KFjza.

  5. changed the title [-]How to set the layer order?[/-] [+]`axes.boxplot` does not have zorder kwarg[/+] on Sep 24, 2016
  6. added this to the milestone on Sep 24, 2016
  7. added
    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Sep 24, 2016
  8. tacaswell commented on Sep 24, 2016

    @tacaswell
    Member

    re-titled and re-opened, boxplot should take zorder as a kwrag.

  9. efiring commented on Sep 24, 2016

    @efiring
    Member

    @nancysendoh, for your immediate problem, try raising the scatter plot by supplying scatter a "zorder=2.5" kwarg. That will put its patch collection above the Line2D default zorder of 2 that is used by boxplot.

  10. nancysendoh commented on Sep 25, 2016

    @nancysendoh
    Author

    Thanks a lot~![☺]


    发件人: Eric Firing notifications@github.com
    发送时间: 2016年9月24日 18:46
    收件人: matplotlib/matplotlib
    抄送: Cookie; Mention
    主题: Re: [matplotlib/matplotlib] axes.boxplot does not have zorder kwarg (#7171)

    @nancysendohhttps://github.com/nancysendoh, for your immediate problem, try raising the scatter plot by supplying scatter a "zorder=2.5" kwarg. That will put its patch collection above the Line2D default zorder of 2 that is used by boxplot.

    —
    You are receiving this because you were mentioned.
    Reply to this email directly, view it on GitHubhttps://github.com//issues/7171#issuecomment-249380894, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJwUtO3s7RZrSOx9KOaUXofIHiQj40_bks5qtW_xgaJpZM4KFjza.

  11. afvincent commented on Feb 19, 2017

    @afvincent
    Contributor

    Closing: the zorder kwarg was added in #7178 :).

  12. modified the milestones: , on Feb 19, 2017
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

    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesNew feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions