Python's textwrap function isn't working for me in Seaborn: https://docs.python.org/3/library/textwrap.html
I followed this tutorial to wrap the text on my xtick labels: https://medium.com/dunder-data/automatically-wrap-graph-labels-in-matplotlib-and-seaborn-a48740bc9ce
However when I run my code, I get no error message and my x-axis ticks are still overlapping. I pasted relevant parts of my code below. Any help would be greatly appreciated!
########### Libraries used for my code
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
from openpyxl.workbook import Workbook
from openpyxl import load_workbook
from openpyxl.drawing.image import Image
import xlwings as xw
import textwrap
from textwrap import wrap
########### Defining bar plot parameters
fig, ax = plt.subplots (figsize= (10.95,4.23))
sns.set_style('whitegrid')
ax = sns.barplot(data=data, x='Kinase Target',
y=ws['C2'].value,width=1,hue='Group')
########### Format x-axis based on number of rows
rows_count = data.shape[0]
if 10 > rows_count >= 0 :
plt.xticks(rotation =45,horizontalalignment='right',
fontweight='bold', fontsize = 12)
plt.subplots_adjust(top=0.85, bottom=0.8, left=0.073, right=0.852)
########### I want to wrap xtick label text as part of my first if statement
def wrap_labels(ax, width, break_long_words=False):
labels = []
for label in ax.get_xticklabels():
text = label.get_text()
labels.append(textwrap.fill(text, width, break_long_words=break_long_words))
ax.set_xticklabels(labels, rotation=0)
wrap_labels(ax, 0.5)
ax.figure
########### Next if statement (I go on to format other parts of the graph like title and y ticks)
elif 20 > rows_count >= 10 :
plt.xticks(rotation = 45,horizontalalignment='right', fontweight='bold', fontsize = 10)