标记在 seaborn 图中不可见 [英] Markers are not visible in seaborn plot
问题描述
这是一个例子:
import seaborn as sns
ax = sns.lineplot(range(10), range(10), markers=True)
为什么我设置了 markers=True
却没有任何标记?
Why aren't there any markers although I set markers=True
?
推荐答案
基本上,因为那不是 markers=
的用途.正如根据文档:
Basically, because that's not what markers=
is for. As per the documentation:
markers:布尔值、列表或字典,可选
markers : boolean, list, or dictionary, optional
对象确定如何为样式变量的不同级别绘制标记.设置为 True 将使用默认标记,或者您可以传递一个列表标记或字典将样式变量的级别映射到标记.设置为 False 将绘制无标记线.标记是在 matplotlib 中指定.
Object determining how to draw the markers for different levels of the style variable. Setting to True will use default markers, or you can pass a list of markers or a dictionary mapping levels of the style variable to markers. Setting to False will draw marker-less lines. Markers are specified as in matplotlib.
因此,markers=
仅在您还指定了 style=
参数时才有用.例如:
Therefore, markers=
is only useful when you also specify a style=
parameter. For example:
fmri = sns.load_dataset("fmri")
ax = sns.lineplot(x="timepoint", y="signal", style="event", data=fmri, markers=True)
但是,其他 kwargs 会传递给 plt.plot()
,因此,您可以使用 marker=
指示 lineplot
使用标记> kwarg(注意缺少s"):
However, other kwargs are passed to plt.plot()
, therefore, you can instruct lineplot
to use markers by using the marker=
kwarg (notice the lack of "s"):
ax = sns.lineplot(range(10), range(10), marker='o')
这篇关于标记在 seaborn 图中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!