在 pandas-profiling 中自定义绘图(在相关热图中更改 colors/colorbar/..)

Customise plots in pandas-profiling (change colors/colorbar in correlation heatmap/..)

我搜索了 pandas 分析文档,他们的 advanced usage webpage but I could not find how to customise plots that it generates. Eg. now it shows correlation matrices with colorbar having blue as 1 and red as -1. What if I want to reverse the colours? Or change the palette fully? The advanced options allow to skip some parts or change defaults for computing correlations but is it possible to pass arguments to the underlying matplotlib? My guess is that this 负责相关图,但是 a) 我不知道如何将任何东西传递给它; b) 其他情节(例如互动)呢?

方法是使用 plot 参数,然后更改 cmap。当时没有记录。可以使用 seaborn 或他们自己的任何调色板,也可以调整其他绘图设置。语法是:

import seaborn as sns
from pandas_profiling import ProfileReport

planets = sns.load_dataset("planets")

# drop the one participant who did not submit
profile = ProfileReport(planets, title='Pandas Profiling Report', explorative=True,
                       plot={
                           'correlation':{
                               'cmap': 'RdBu_r',
                               'bad': '#000000'}}
                       )
# profile.to_widgets()
profile.to_notebook_iframe()

产量:

所有可能的微调和调整以及默认设置都在 this