Sea point over the tombstone

I am trying to plot group wise median values โ€‹โ€‹using a nautical dot above the word swarmplot. Even though I call pointPlot second, the plot ends behind swarmplot. How do I change the "layer order" so that the point plot is in front of the swarmplot?

datDf=pd.DataFrame({'values':np.random.randint(0,100,100)})
datDf['group']=np.random.randint(0,5,100)
sns.swarmplot(data=datDf,x='group',y='values')
sns.pointplot(data=datDf,x='group',y='values',estimator=np.median,join=False)

      

enter image description here

+3


source to share


1 answer


Use the property zorder

to set the correct drawing order .

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pylab as plt

datDf=pd.DataFrame({'values':np.random.randint(0,100,100)})
datDf['group']=np.random.randint(0,5,100)
sns.swarmplot(data=datDf,x='group',y='values',zorder=1)
sns.pointplot(data=datDf,x='group',y='values',estimator=np.median,join=False, zorder=100)
plt.show()

      



enter image description here

+4


source







All Articles