如果我需要进行特定的更改或面向细节的可视化,我已经学会了不要使用seaborn,但我觉得我有时没有充分利用它所提供的功能。
我想专门用seaborn 指定调色板。我不确定我是否遗漏了一些东西,或者这是使用facetgrid时无法解决的细节?
df = pd.DataFrame()
df['I'] = np.full(20,1)
df['J'] = np.arange(0,20,1)
df['K'] = [1]*12 + [2]*8
df['CM_Hard'] = [1]*10 + [2] + [0] + [2]*8
df['Realization'] = ['p25']*10 + ['p50']*9 + ['p75']
for layer in df['K'].unique():
layer_data_slice = df.groupby('K').get_group(layer)
g = sns.FacetGrid(layer_data_slice, col="Realization",hue="CM_Hard")
g.map_dataframe(sns.scatterplot, x="I", y="J", s=50, marker='+', palette='deep')
g.add_legend()
g.fig.suptitle("Training Realizations, Layer: {}".format(int(layer)), size=16, y=1.05)
figure_title = 'Training_Layer_{}'.format(int(layer))
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下内容进行调色板定义,但它不会影响绘图:
palette = {0:"tab:cyan", 1:"tab:orange", 2:"tab:purple"}
Run Code Online (Sandbox Code Playgroud)
已尝试使用“tab:color”、“color”和 RGB 参考,但没有成功。没有错误,它只是在更改时不执行任何操作。