It's probably a trivial question, but I am trying to plot a bar chart with matplotlib and with rotated text on the x axis. The code I'm using is shown below:
fig = plt.figure()
x_labels_list = []
for i in range(0, pow(2, N)):
x_labels_list.append(str(f(i))) # The function f() converts i to a binary string
ax = plt.subplot(111)
width = 1.0
bins = map(lambda x: x-width, range(1,pow(2,N)+1))
ax.bar(bins, my_data, width=width)
ax.set_xticks(map(lambda x: x-width/2, range(1,pow(2,N)+1)))
ax.set_xticklabels(x_labels_list, rotation=90, rotation_mode="anchor", ha="right")
It works perfectly, but I obtain an annoying white space on the right of the x axis, as shown by the red ellipse in the following picture:
Do you know how I can remove it? Thanks in advance!