Osmond Bishop
Osmond Bishop

Reputation: 8180

Editing bounds to get rid of white-space within a plot in matplotlib

enter image description here![Left: Data from 2000-2040, Right: Data from 2001-2039][2]

Is there a way I can manually edit the bounds of my plot? When my x axis data runs from 2000 to 2040 matplotlib rearranges the plot such that a lot of white-space is produced on both the left and right sides of the plot, as in the left picture. However when I change my x axis data from 2001 to 2039 there is no whitespace as in the right picture. I suspect this happens because of how matplotlib automatically arranges the ticks. The question is how can the x-ticks be manipulated manually to avoid unnecessary whitespace? Any ideas?

Upvotes: 0

Views: 1383

Answers (1)

BrenBarn
BrenBarn

Reputation: 251365

You can use the various pyplot functions called xlim, ylim (to set the limits of the axes), xticks, yticks (to set the tick positions) etc. Read the documentation.

Upvotes: 2

Related Questions