Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Seaborn条纹图删除条纹图_Python_Matplotlib_Seaborn_Boxplot - Fatal编程技术网

Python Seaborn条纹图删除条纹图

Python Seaborn条纹图删除条纹图,python,matplotlib,seaborn,boxplot,Python,Matplotlib,Seaborn,Boxplot,我有一个箱线图: fig, ax = plt.subplots(1,1) bp = df.boxplot(column='transaction_value', by='store_type', grid=True, ax=ax, showfliers=True) plt.tight_layout(rect=[0, 0.03, 1, 0.95]) ax.set_ylim([0, 800]) ax.set_ylabel('transaction_va

我有一个箱线图:

fig, ax = plt.subplots(1,1)
bp = df.boxplot(column='transaction_value', 
           by='store_type', grid=True, 
           ax=ax, showfliers=True)
plt.tight_layout(rect=[0, 0.03, 1, 0.95])
ax.set_ylim([0, 800])
ax.set_ylabel('transaction_value')
plt.show()
我有一个海生条纹图:

bplot=sns.stripplot(y='transaction_value', x='store_type', 
                   data=df, 
                   jitter=True, 
                   marker='o', 
                   alpha=0.1,
                   color='black')
当我试图在箱线图上覆盖条带图时,它会删除最左边的第一个箱线图

fig, ax = plt.subplots(1,1)
bp = df.boxplot(column='transaction_value', 
           by='store_type', grid=True, 
           ax=ax, showfliers=True)
bplot=sns.stripplot(y='transaction_value', x='store_type', 
                   data=df, 
                   jitter=True, 
                   marker='o', 
                   alpha=0.1,
                   color='black')
plt.tight_layout(rect=[0, 0.03, 1, 0.95])
ax.set_ylim([0, 500])
ax.set_ylabel('transaction_value')
plt.show()
我怎样才能阻止这种事情发生

添加数据示例:
@ImportantanceOfBeingernest在我打字时在评论中提供了一个解决方案,但我想提出一些其他建议:

为了更好的一致性,我建议也使用seaborn绘制箱线图,这应确保两个图的布局方式相同

fig, ax = plt.subplots(1,1)
sns.boxplot(y='transaction_value', x='store_type', data=df, ax=ax, 
            color='w')
sns.stripplot(y='transaction_value', x='store_type', data=df, ax=ax,
                   jitter=True, 
                   marker='o', 
                   alpha=0.1,
                   color='black')

ax.set_ylabel('transaction_value')
plt.show()

似乎stripplot和boxplot在放置每个类别的位置上无法达成一致。带状图在[0-3]处绘制,盒状图在[1-4]处绘制。如果能提供一个有效的解决方案,那将是很有帮助的。提供模型数据。具体请参考@DizietAsahi使用示例数据添加的示例。CheeserSDF.boxplot…,位置=np.arange4。为了以防万一,请在stripplot中使用order参数,以确保两个绘图相互关联。@ImportanceOfBeingErnest干杯。你想添加真实答案还是重复?如果你发现一个应该存在的重复答案,但可能不是针对boxplot和stripplot的精确组合?你可以这样做。干杯,迪齐特,在这个场合,我想让他们熊猫/海洋出生分开,但这是可行的。
fig, ax = plt.subplots(1,1)
sns.boxplot(y='transaction_value', x='store_type', data=df, ax=ax, 
            color='w')
sns.stripplot(y='transaction_value', x='store_type', data=df, ax=ax,
                   jitter=True, 
                   marker='o', 
                   alpha=0.1,
                   color='black')

ax.set_ylabel('transaction_value')
plt.show()