10
Seaborn允许定义包含多种颜色的调色板,适用于多行图表。但是,当将调色板设置为多种颜色时,只会使用前六种颜色,之后颜色将循环使用,从而难以区分线条。这可以通过显式调用调色板来覆盖,但这不方便。有没有办法强制Seaborn电流调色板不要回收颜色,当超过6个定义?Seaborn调色板 - 防止颜色回收
实施例:
from matplotlib import pyplot as plt
import pandas as pd
import seaborn as sb
# Define a palette with 8 colors
cmap = sb.blend_palette(["firebrick", "palegreen"], 8)
sb.palplot(cmap)
# Set the current palette to this; only 6 colors are used
sb.set_palette(cmap)
sb.palplot(sb.color_palette())
df = pd.DataFrame({x:[x*10, x*10+5, x*10+10] for x in range(8)})
fig, (ax1, ax2) = plt.subplots(2,1,figsize=(4,6))
# Using the current palette, colors repeat
df.plot(ax=ax1)
ax1.legend(bbox_to_anchor=(1.2, 1))
# using the palette that defined the current palette, colors don't repeat
df.plot(ax=ax2, color=cmap)
ax2.legend(bbox_to_anchor=(1.2, 1)) ;
闻起来像一个seaborn错误给我。 – tacaswell 2014-10-10 14:08:27
我也是,但我不想做出假设 – iayork 2014-10-10 14:11:58
实际上,我不这么认为:http://web.stanford.edu/~mwaskom/software/seaborn/generated/seaborn.color_palette.html它看起来像它正在做它应该做的事情,它只是令人讨厌。 – tacaswell 2014-10-10 14:13:37