使用Seaborn,我可以在同一个图上创建一个pandas DataFrame
的多列的箱线图。我想对传单(离群值)应用自定义样式,例如设置标记符号、颜色和标记大小。
但是,The API documentation on seaborn.boxplot只提供了一个参数fliersize
,它允许我控制传单的大小,而不是颜色和符号。
由于Seaborn使用matplotlib进行绘图,我想我可以为boxplot
函数提供一个matplotlib样式字典,如下所示:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# create a dataframe
df = pd.DataFrame({'column_a': [3, 6, 200, 100, 7], 'column_b': [1, 8, 4, 150, 290], 'column_c': [6, 7, 20, 80, 275]})
# set figure size
sns.set(rc={"figure.figsize": (14, 6)})
# define outlier properties
flierprops = dict(marker='o', markersize=5)
# create boxplot
ax = sns.boxplot(df, vert=False, showmeans=True, flierprops=flierprops)
plt.show()
结果:
根据提供的字典,我希望有一个大的红色圆圈代表column_c
的传单,但是仍然使用标准设置。
This thread describes a similar problem当直接使用matplotlib时-但是,从讨论中我猜,在使用最新版本的matplotlib时,应该同时修复这个问题。
我用一个iPython笔记本(iPython 3.10)、matplotlib 1.4.3和seaborn 0.5.1进行了尝试。
目前没有回答
相关问题 更多 >
编程相关推荐