Well, `plt.title()` has a parameter `pad=` to set the padding between the text of the title and the top spine of the plot. `plt.xlabel()` and `plt.ylabel()` have a parameter `labelpad=` to set the distance between the axis label and the ticklabels.
`sns.heatmap()` has a parameter `annot_kws` which is a dictionary of parameters for the annotation texts. The color can be changed via `sns.heatmap(..., annot_kws={'size': 16, 'color': 'black'})`
```python
from matplotlib import pyplot as plt
import matplotlib
import numpy as np
import seaborn as sns
def NonLinCdict(steps, hexcol_array):
cdict = {'red': (), 'green': (), 'blue': ()}
for s, hexcol in zip(steps, hexcol_array):
rgb = matplotlib.colors.hex2color(hexcol)
cdict['red'] = cdict['red'] + ((s, rgb[0], rgb[0]),)
cdict['green'] = cdict['green'] + ((s, rgb[1], rgb[1]),)
cdict['blue'] = cdict['blue'] + ((s, rgb[2], rgb[2]),)
return cdict
hc = ['#e5e5ff', '#C7DDF2', '#8EBAE5', '#407FB7', '#00549F'] # ffffff #e5e5ff
th = [0, 0.25, 0.5, 0.75, 1]
hc = hc[:0:-1] + hc # prepend a reversed copy, but without repeating the central value
cdict = NonLinCdict(np.linspace(0, 1, len(hc)), hc)
cm = matplotlib.colors.LinearSegmentedColormap('test', cdict)
corr = np.random.uniform(-1, 1, (6, 6))
# plot correlation matrix:
plt.figure(figsize=(10, 8))
ax = sns.heatmap(corr, center=0, linewidths=1, annot=True, cmap=cm, square=True, vmin=-1, vmax=1,
robust=True, annot_kws={'size': 16, 'color': 'black'}, cbar=True, linecolor='#F6A800',
xticklabels=True,
yticklabels=True)
cbar = ax.collections[0].colorbar
cbar.ax.tick_params(labelsize=10, axis='both', which='both', length=0)
cbar.set_ticks(np.linspace(-1, 1, 11))
plt.title("title", y=-1.5, fontsize=18, pad=15)
plt.xlabel("X_parameters", fontsize=18, labelpad=15)
plt.ylabel("Y_paramaters", fontsize=18, labelpad=15)
ax.tick_params(axis='both', which='both', length=0)
ax.axhline(y=0, color='#F6A800', linewidth=4)
ax.axhline(y=corr.shape[1], color='#F6A800', linewidth=4)
ax.axvline(x=0, color='#F6A800', linewidth=4)
ax.axvline(x=corr.shape[0], color='#F6A800', linewidth=4)
plt.show()
```
[![resulting plot][1]][1]
[1]: https://i.stack.imgur.com/ec92J.png
You can grab the colorbar via `ax.collections[0].colorbar`. From there you can change the tick properties.
Here is a minimal example:
```python
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
def NonLinCdict(steps, hexcol_array):
cdict = {'red': (), 'green': (), 'blue': ()}
for s, hexcol in zip(steps, hexcol_array):
rgb = matplotlib.colors.hex2color(hexcol)
cdict['red'] = cdict['red'] + ((s, rgb[0], rgb[0]),)
cdict['green'] = cdict['green'] + ((s, rgb[1], rgb[1]),)
cdict['blue'] = cdict['blue'] + ((s, rgb[2], rgb[2]),)
return cdict
hc = ['#e5e5ff', '#acacdf', '#7272bf', '#39399f', '#000080', '#344152']
hc = hc[:0:-1] + hc # prepend a reversed copy, but without repeating the central value
cdict = NonLinCdict(np.linspace(0, 1, len(hc)), hc)
cm = matplotlib.colors.LinearSegmentedColormap('test', cdict)
fig = plt.figure(figsize=(8, 6))
ax = sns.heatmap(np.random.uniform(-1, 1, (10, 10)), center=0, linewidths=.2, annot=True, fmt='.2f', cmap=cm, vmin=-1, vmax=1, cbar=True)
ax.tick_params(axis='both', which='both', length=0)
cbar = ax.collections[0].colorbar
cbar.ax.tick_params(labelsize=15, axis='both', which='both', length=0)
cbar.set_ticks(np.linspace(-1, 1, 11))
# cbar.set_label('correlation')
plt.show()
```
[![example plot][1]][1]
[1]: https://i.stack.imgur.com/C5auz.png