You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to draw boxplot and scatter in one figure, but the boxplot always covers the points as below:
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()
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!
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.
@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.
发件人: 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.
Activity
[-]How to set the layer irder?[/-][+]How to set the layer order?[/+]Phlya commentedon Sep 24, 2016
Use
zorderargument in plotting commands, the higher the value, the more on top will be the objects.Kojoley commentedon Sep 24, 2016
Please do not use the issue tracker to ask questions, use mailing list or gitter for this. https://github.com/matplotlib/matplotlib#contact
nancysendoh commentedon Sep 24, 2016
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.
[-]How to set the layer order?[/-][+]`axes.boxplot` does not have zorder kwarg[/+]tacaswell commentedon Sep 24, 2016
re-titled and re-opened, boxplot should take
zorderas a kwrag.efiring commentedon Sep 24, 2016
@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.
nancysendoh commentedon Sep 25, 2016
Thanks a lot~![☺]
发件人: Eric Firing notifications@github.com
发送时间: 2016年9月24日 18:46
收件人: matplotlib/matplotlib
抄送: Cookie; Mention
主题: Re: [matplotlib/matplotlib]
axes.boxplotdoes 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.
afvincent commentedon Feb 19, 2017
Closing: the
zorderkwarg was added in #7178 :).