通常,我会通过编辑matplotlib.rcParams来增加matplotlib的全局线宽.这似乎可以直接用于SciPy’s dendrogram实现,而不适合Seaborn’s clustermap(使用SciPy的树状图).谁能建议一种可行的方法?
import matplotlib
matplotlib.rcParams['lines.linewidth'] = 10
import seaborn as sns; sns.set()
flights = sns.load_dataset("flights")
flights = flights.pivot("month", "year", "passengers")
g = sns.clustermap(flights)
解决方法:
对于较新版本的seaborn(经过0.7.1、0.9.0测试),这些行位于LineCollection中,而不是单独存在.因此,它们的宽度可以如下更改:
import seaborn as sns
import matplotlib.pyplot as plt
# load data and make clustermap
df = sns.load_dataset('iris')
g = sns.clustermap(df[['sepal_length', 'sepal_width']])
for a in g.ax_row_dendrogram.collections:
a.set_linewidth(10)
for a in g.ax_col_dendrogram.collections:
a.set_linewidth(10)