Truncated Heatmap Rows: Pitfalls with Matplotlib and Seaborn
Question:
Users have observed that the first and last rows of heatmaps generated using Seaborn are cut in half. This issue persists even when running minimal code examples, as demonstrated below:
import pandas as pd import seaborn as sns import matplotlib.pyplot as plt data = pd.read_csv('https://raw.githubusercontent.com/resbaz/r-novice-gapminder-files/master/data/gapminder-FiveYearData.csv') plt.figure(figsize=(10,5)) sns.heatmap(data.corr()) plt.show()
Answer:
Unfortunately, matplotlib 3.1.1 has been found to be incompatible with Seaborn heatmaps and inverted axes with fixed ticks. To rectify this issue:
ax.set_ylim(bottom, top) # set the ylim to bottom, top
The above is the detailed content of Why are My Seaborn Heatmaps Truncating the First and Last Rows?. For more information, please follow other related articles on the PHP Chinese website!