import pandas as pd
import matplotlib.pyplot as plt
# data
data = {"yLabels": [" Ticklabel1", "Ticklabel2", "Ticklabel3"], "Total":[10.3, 7.5, 3.6]}
dataFrame = pd.DataFrame(data = data);
# figure
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(10,3))
fig.patch.set_facecolor('#bbffbb')
# Plot
dataFrame.plot.barh(x='yLabels', y='Total', title="", figsize=(10,3), ax=ax)
ax.get_legend().remove()
ax.yaxis.set_label_text(None);
plt.show();
Results in:
Question: Is it possible to exactly specify the width before the y-axis (see red arrow), independent of the lenght of the ticklabels, and without affecting the total width (the width of the green area).
So, for example, if the width before the y label (the red arrow) increases, the width of the plot (the grey area) degreases. The total width (the green area) stays the same.
CodePudding user response:
A tricky solution would be to make extra whitespaces in the ticklabels with
N = 50