Reputation: 1345
I have a seaborn plot and I would like to create custom tick label coloring for it.
The code is:
short_cols = ['col_1', 'col_2', 'col_3', 'col_4', 'col_5', 'col_6', 'col_7', 'col_8', 'col_9', 'col_10', 'col_11', 'col_12', 'col_13', 'col_14', 'col_15', 'col_16', 'col_17', 'col_18', 'col_19']
fig, ax = plt.subplots(figsize=(13,10))
sns.heatmap(jr_matrix,
center=0,
cmap="vlag",
linewidths=.75,
ax=ax,
norm=LogNorm(vmin=jr_matrix.min(), vmax=jr_matrix.max()))
ax.set_xticklabels(short_cols, rotation=90, size=14, labelcolor='red')
ax.set_yticklabels(short_cols, rotation=0, size=14)
The plot looks like this:
There is a certain grouping between some of the items in short_cols such that it would be useful to be able set them to the same color.
My question is, how can I adjust the ticklabel colors so that I can reflect this association in the plot.
For example, lets say the groups are:
group1 = ['col_1', 'col_2', 'col_3']
group2 = ['col_4', 'col_5']
group3 = ['col_6']
...
group7=['col_18', 'col_19']
Any help here would be much appreciated.
Upvotes: 2
Views: 7489
Reputation: 61
confusion_M = pd.crosstab(model1_pred.Predicted_class,model1_pred.Actual_class)
sn.set(rc={'axes.facecolor':'black', 'figure.facecolor':'black',})
fig = plt.figure(figsize=(13,10))
g= sn.heatmap(confusion_M,annot=True,cmap = "coolwarm",fmt = ".1f",annot_kws=
{'size':100})
for tick_label in g.axes.get_yticklabels():
tick_label.set_color("white")
tick_label.set_fontsize("30")
fig.tight_layout()
Upvotes: 6