python - Add custom border to certain cells in a matplotlib / seaborn plot -
right i`m using seaborn's clustermap generate clustered heatmaps - far good.
for use case, need draw colored borders around specific cells. there way that? or pcolormesh in matplotlib, or other way?
you can overplotting rectangle patch on cell want highlight. using example plot seaborn docs
import seaborn sns import matplotlib.pyplot plt sns.set() flights = sns.load_dataset("flights") flights = flights.pivot("month", "year", "passengers") g = sns.clustermap(flights)
we can highlight cell doing
from matplotlib.patches import rectangle ax = g.ax_heatmap ax.add_patch(rectangle((3, 4), 1, 1, fill=false, edgecolor='blue', lw=3)) plt.show()
this produce plot highlighted cell so:
note the indexing of cells 0 based origin @ bottom left.
Comments
Post a Comment