简体   繁体   中英

Lines to separate groups in seaborn heatmap

I am plotting data as a Seaborn heatmap in Python. My data is intrinsically grouped into categories, and I'd like to have lines on the plot to indicate where the groups lie on the map. As a simple example, suppose I wanted to modify this plot from the documentation...

import seaborn as sns; sns.set()
flights = sns.load_dataset("flights")
flights = flights.pivot("month", "year", "passengers")
ax = sns.heatmap(flights, cbar=False)

在此输入图像描述

Where I wanted to emphasize the comparisons between quarters of the year by making a plot like the one below; how would I do that?

在此输入图像描述

你想要ax.hlines

ax.hlines([3, 6, 9], *ax.get_xlim())

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM