[Python] python - matplotlib closes window immediately

Discussão em 'Python' iniciado por Stack, Fevereiro 2, 2025.

  1. Stack

    Stack Membro Participativo

    I have created a sin wave in matplotlib and when I run the code the the window opens and closes immediately without showing anything. What can I do to display the results.

    import torch, time
    import numpy as np
    import pandas as pd
    import matplotlib.pyplot as plt

    # Create sine wave data
    pi_tensor = torch.linspace(0, 2 * np.pi, 100)
    sin_result = torch.sin(pi_tensor)

    # Plot the sine wave
    plt.plot(pi_tensor.numpy(), sin_result.numpy())
    plt.show()

    Continue reading...

Compartilhe esta Página