Skip to content

axes.boxplot does not have zorder kwarg #7171

Closed
@nancysendoh

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

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