[Python] Python: How can I change the x axis of an plt.imshow to a linspace instead of...

Discussão em 'Python' iniciado por Stack, Julho 29, 2025.

  1. Stack

    Stack Membro Participativo

    Assume each sample in the data was taken at 30us interval. The current plot shows the sample number in the x-axis. How can I change the x axis of an plt.imshow to the time linspace ?

    import numpy as np
    import matplotlib.pyplot as plt

    data = np.random.random((10, 5))

    # time
    T = 30e-6
    time = np.linspace(0, (data.shape[1]-1)*T, num=data.shape[1])

    # plot
    plt.imshow(data, aspect='auto')
    plt.ylabel('channel')
    plt.xlabel('sec')
    plt.colorbar(label="amplitude")
    plt.show()

    Continue reading...

Compartilhe esta Página