【问题标题】:Customise plots in pandas-profiling (change colors/colorbar in correlation heatmap/..)自定义 pandas-profiling 中的图(更改相关热图中的颜色/颜色条/..)
【发布时间】:2021-06-03 22:20:18
【问题描述】:

我搜索了 pandas 分析文档和他们的 advanced usage 网页,但我找不到如何自定义它生成的图。例如。现在它显示了颜色条的相关矩阵,蓝色为 1,红色为 -1。如果我想反转颜色怎么办?或者完全改变调色板?高级选项允许跳过某些部分或更改计算相关性的默认值,但是否可以将参数传递给底层 matplotlib?我的猜测是this 负责相关图但是a)我不知道如何将任何东西传递给它; b) 其他情节(例如交互)呢?

【问题讨论】:

  • 我觉得this answer 很有帮助
  • 我知道如何在matplotlib中反转cmap,我不知道如何将它传递给pandas-profiling。

标签: python pandas pandas-profiling


【解决方案1】:

如何做到这一点的方法是使用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

【讨论】:

    猜你喜欢
    • 2020-06-21
    • 2020-12-07
    • 2020-10-21
    • 2018-02-08
    • 2021-07-06
    • 2015-02-19
    • 2020-12-26
    • 2021-09-24
    • 1970-01-01
    相关资源
    最近更新 更多