1

I am trying to make a bar chart in python using matplotlib. Here is my code

fig = plt.figure(figsize=(6.5, 3), dpi=300) 
plt.bar(y_pos, X, align='center', color='red', ecolor='black')
plt.bar(y_pos, X, align='center', color='green', ecolor='black')
plt.bar(y_pos, X, align='center', color='blue', ecolor='black')
plt.bar(y_pos, X, align='center', color='orange', ecolor='black')

plt.ylabel("Rate", size=8)
plt.xlabel("Label", size=8)
plt.xticks(np.arange(1,57,1))
plt.ylim([50,100])
plt.tick_params(axis='x', which='major', labelsize=4)
plt.tick_params(axis='y', which='major', labelsize=6)
plt.show()

But problem is the unwanted space around the bars. How can I remove this white space?
enter image description here

Arslan
  • 179
  • 1
  • 1
  • 9

1 Answers1

0

You can use the function tight_layout() before displaying the figure.