def get_palette(self):
"""
Return a palette that is suitable for the data.
"""
# choose the "Paired" palette if the number of grouping factor
# levels is even and below 13, or the "Set3" palette otherwise:
if len(self._levels) == 0:
if len(self._groupby) == 1:
return sns.color_palette("Paired")[0]
else:
palette_name = "Paired"
elif len(self._levels[-1]) in (2, 4, 6):
palette_name = "Paired"
else:
# use 'Set3', a quantitative palette, if there are two grouping
# factors, or a palette diverging from Red to Purple otherwise:
palette_name = "Paired" if len(self._groupby) == 2 else "RdPu"
return sns.color_palette(palette_name)
评论列表
文章目录