[英]seaborn pointplot above swarmplot
I try to plot group wise median values using seaborn's pointlot
on top of a swarmplot.我尝试在群图上使用 seaborn 的
pointlot
绘制分组明智的中值。 Even though I call pointPlot second, the point plot ends up behind the swarmplot.即使我将 pointPlot 称为第二个,点图最终还是在 swarmplot 后面。 How can I change the 'layer order' such 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)
Use zorder
property to set proper drawing order .使用
zorder
属性设置正确的 绘制顺序。
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.