Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
Hi eveybody,
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 pltimport numpy as npx=[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 colorcolor = 'blue'for patch in bplot1['boxes']: patch.set_facecolor(color) patch.set_alpha(0.5)plt.savefig('1.jpg',dpi=100)plt.show()