Donghui HU
Donghui HU

Reputation: 91

change seaborn pairplot legend alpha/color

grid = sns.pairplot(data=vst_wgcna, hue='cluster', kind="reg",
                palette=palette, corner=True,
           plot_kws={ 'scatter_kws': {'alpha': 0.05}})

grid.map_offdiag(plot_unity,  plot_kws={ 'scatter_kws': {'alpha': 0.1}})
grid._legend.set_bbox_to_anchor((0.81, 0.5))

The legend have color dots before the “positive modules" and "negative modules", because I set alpha to 0.05, it is very hard to see. how to fix that? enter image description here

Upvotes: 2

Views: 554

Answers (1)

Donghui HU
Donghui HU

Reputation: 91

As JohanC commented, we can loop through the legend handles and change their alpha:

for handle in grid.legend.legendHandles:
    handle.set_alpha(0.7)

Upvotes: 1

Related Questions