Markers are not visible in seaborn plot

£可爱£侵袭症+ 提交于 2020-01-24 09:23:31

问题


Here is an example:

import seaborn as sns
ax = sns.lineplot(range(10), range(10), markers=True)

Why aren't there any markers although I set markers=True?


回答1:


Basically, because that's not what markers= is for. As per the documentation:

markers : boolean, list, or dictionary, optional

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.

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)

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')



回答2:


A similar problem was found here. If you specify the matplotlib argument using marker='*' for example the markers will show up.



来源:https://stackoverflow.com/questions/57485426/markers-are-not-visible-in-seaborn-plot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!