Search code examples
pythonmatplotlibgraphfigure

Change tick interval with matplotlib.figure


Is there a way to change the interval for the x-value? they're pretty clumped up right now and i dont need to show everyone, i may only need to show 1 per 20.

Pic of the graph

def create_window_graph(xas,yas,labname):

fig = Figure(figsize=(8, 4), dpi=80)

fig.add_subplot(111).plot(xas,yas, 'r--', label = labname) 


fig.legend()

Solution

  • Using maptplotlib.pyplot it's pretty straightforward:

    ax.set_xlim(xmin = , xmax = )

    You can see the full documentation here:

    https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.set_xlim.html