[Python] How to make matplotlib show all x coordinates?

Discussão em 'Python' iniciado por Stack, Abril 10, 2025.

  1. Stack

    Stack Membro Participativo

    For example in the following code:

    import numpy as np
    import matplotlib.pyplot as plt

    N = 10
    x = [1,2,3,4,5,6,7,8,9,10]
    y = np.random.rand(N)

    plt.scatter(x, y)
    plt.show()


    I get the following plot

    [​IMG]

    as you can see, in the x axis, only the even values appear. How to force matplotlib to show all values, that is 1 2 3 4 5 6 7 8 9 10?

    Continue reading...

Compartilhe esta Página