Pandas的盒子图,但不显示盒子

2024-10-01 11:26:28 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有什么方法可以使用箱线图但只显示点?在

我有这个:

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

data2 = pd.DataFrame(dict(site85_574C=[10,20,30,40, 50], site41_366A=[5,15, 25, 35, 45]),  columns=["site85_574C", "site41_366A"])
data2.boxplot(widths=0.05)
plt.scatter(np.repeat(np.arange(data2.shape[1])+1, data2.shape[0]), data2.values.ravel(), marker='+', alpha=1.0)

但我只想看到垂直线上的点,而不是盒子和胡须

enter image description here


Tags: 方法importnumpypandasasnppltseaborn