The graph is plotted with python's maplotlib.

import matplotlib.pyplot as plt
import numpy as np
x = np.linspace (0, 2 * np.pi, 100)
fig = plt.figure ()
ax = fig.add_subplot (1,1,1)
ax.plot (x, np.sin (x))

You can plot it now, but how can you make the minimum and maximum values ​​of the axis at this time?
Show me just right.
I would like to see this value again. Is this possible?

  • Answer # 1

    The current maximum and minimum are the X axis and Y axis respectively

    ax.get_xlim ()
    ax.get_ylim ()
    You can get it with


    To set it, useset_xlim ()set_ylim ()

    ax.set_xlim (0, 2 * np.pi)
    ax.set_ylim (-1, 1)
    It can be set like