0

I have the following matplotlib code which all it does is plot in full screen (because that's how the x-axis looks good), however the y-axis has wasted space as you see.

dictionary.sort(key=lambda x: x[0], reverse=True)
hierarchies = list(zip(*dictionary))[0]
score = list(zip(*dictionary))[1]
x_pos = np.arange(len(hierarchies))
y_pos = np.arange(max(dictionary, key=itemgetter(1))[1] + 2)
plt.yticks(x_pos, hierarchies)
plt.xticks(y_pos)
plt.xlabel("Frequency")
title_label = "Year: " + year + "     " + "||" + "     " + "No. thesis: " + str(count_thesis)
plt.title(title_label, loc="center")
plt.barh(x_pos, score, align="center")
plt.tight_layout()
manager = plt.get_current_fig_manager()
manager.window.showMaximized()
plt.show()

Matplotlib Figure

I used "plt.tight_layout()" but it doesn't work quite right for me. I was wondering if I could do something to make the graph bigger, like making each Y-label in two rows, or another trick would help.

I hope I'm not too confusing.

Thank you for your help!

iXrst
  • 1
  • 2
  • I find [Wrapping long y labels in matplotlib tight layout using setp](https://stackoverflow.com/questions/15740682/wrapping-long-y-labels-in-matplotlib-tight-layout-using-setp) to be very helpful. I recommend implementing the textwap module. – r-beginners Apr 08 '22 at 04:23

0 Answers0