As indicated above and according to the matplotlib documentation, the x limits of a given axis axis can be set using the set_xlim method of the matplotlib.axes.Axes class.
For example,
>>> ax.set_xlim(left_limit, right_limit) >>> ax.set_xlim((left_limit, right_limit)) >>> ax.set_xlim(left=left_limit, right=right_limit)
One limit can be left unchanged (for example, the left limit):
>>> ax.set_xlim((None, right_limit)) >>> ax.set_xlim(None, right_limit) >>> ax.set_xlim(left=None, right=right_limit) >>> ax.set_xlim(right=right_limit)
To set the x limits of the current axis, the matplotlib.pyplot module contains a xlim function that simply wraps matplotlib.pyplot.gca and matplotlib.axes.Axes.set_xlim .
def xlim(*args, **kwargs): ax = gca() if not args and not kwargs: return ax.get_xlim() ret = ax.set_xlim(*args, **kwargs) return ret
Similarly, for y-limits, use matplotlib.axes.Axes.set_ylim or matplotlib.pyplot.ylim . The key arguments are top and bottom .
Remi Cuingnet Sep 22 '17 at 10:08 on 2017-09-22 10:08
source share