'Box outside my y axis in matplotlib/seaborn
I"m trying to add a descriptive box outside my y axis on my heatmap in matplotlib/seaborn. I tried an additional subplot and hspan, but they weren't working for me. Help please!
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import numpy as np
col1, col2 = np.random.rand(31), np.random.rand(31)
df = pd.DataFrame({'first': col1,
'second': col2}, index = range(70,101))
fig, ax = plt.subplots(1,figsize = (5,10))
sns.heatmap(data=df, annot=True, cmap='RdYlGn', cbar=False)
ax.invert_yaxis()
ax.tick_params('y', labelrotation=0)
Here is a picture of the box beside the y axis for reference.

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
