Home > Net >  uncrop graph image with pyplot
uncrop graph image with pyplot

Time:10-17

To start, I'm using pycharm pro, which only shows plt.show() in image form. I'm making a bar graph where each column has a very long name, and so they have to be vertical. However, right now only a couple letters of each name show up before they are cropped from the graph that is displayed(attached). I've tried plt.set_margins() and plt.autoscale(), to no avail. What can I do to expand the bottom side of this graph so that at least some words of each column name are visible? Another option would be to make each column wide enough to fit some of the name horizontally. I'm assuming this is an easy solution becasue I don't know a lot about pyplot.

Thanksenter image description here

CodePudding user response:

You have 3 possibilities

  1. Make manual adjustments, as shown in the official docs under enter image description here

  2. Use plt.tight_layout() before plt.show()

  3. Instantiate the figure using constrained_layout

    fig, ax = plt.subplots(..., constrained_layout=True)
    ...
    
  • Related