Reputation: 11741
I am creating the following plot and it seems like it's leaving some extra white space on the right hand side and I'm not exactly sure why.
The code to generate the above is given below:
import matplotlib.pyplot as plt
d1 = (0,1,3,6,4,2,2,59,4,3,4,4,33,3,2,5,61)
d2 = (6,7,9,4,4,4,3,19,4,1,11,28,13,8,15,28,28)
d3 = (6,7,9,4,4,4,3,19,4,1,14,28,13,8,15,28,32)
N = len(d1)
ind = np.arange(N)
width = 0.2
font = {'family' : 'sans-serif', 'weight' : 'normal', 'size' : 10}
matplotlib.rc('font', **font)
fig,ax = plt.subplots()
rects1 = ax.bar(ind, MA_DPU, width, color='r', alpha=0.7)
rects2 = ax.bar(ind+width, res1, width, color='b', alpha=0.7)
rects3 = ax.bar(ind+2*width, res2, width, color='g', alpha=0.7)
ax.set_xticks(ind+width*1.5)
plt.show()
Upvotes: 3
Views: 5863
Reputation: 59005
Try to set the xlim
of your Axes
:
ax.set_xlim(0, 16.4)
plt.show()
For convenience you can use "plt.autoscale()":
plt.autoscale()
avoiding to set the xlim
manually.
The optional parameters with their default values are:
plt.autoscale(enable=True, axis='both', tight=None)
Upvotes: 6