[英]How to change fill pattern (hatch) of the Confidence Interval in the Seaborn Lineplot function
I have created a simple lineplot with Seaborn using this code:我使用以下代码使用 Seaborn 创建了一个简单的线图:
sns.lineplot(data=data, x='year', y='Value', color='#128094', linewidth=1, estimator=lambda x: x.sum() / 12)
Which produced this:产生了这个:
How could I change the pattern of the Confidence Interval so I get a hatched pattern such as '\\\\\\'?我怎样才能改变置信区间的模式,这样我就会得到一个阴影模式,比如“\\\\\\”?
err_kws
from seaborn.lineplot
err_kws
的seaborn.lineplot
matplotlib.axes.Axes.fill_between()
or matplotlib.axes.Axes.errorbar()
, depending on err_style
. matplotlib.axes.Axes.fill_between()
或matplotlib.axes.Axes.errorbar()
,具体取决于err_style
。'\\\\\\\\'
) based on {'/', '\\\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
specified in the docs (note that \\
is an escape character and needs to be written twice).'\\\\\\\\'
)基于{'/', '\\\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
在文档中指定(注意\\
是一个转义字符,需要写两次)。import seaborn as sns
import matplotlib.pyplot as plt
flights = sns.load_dataset("flights")
fig, ax = plt.subplots(figsize=(10, 6))
p = sns.lineplot(data=flights, x="year", y="passengers", err_kws={'linestyle': '--', 'hatch': '///', 'fc': 'none'}, ax=ax)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.