[Python] matplotlib.plt adds an unwanted line when using fill_between

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

  1. Stack

    Stack Membro Participativo

    Question about using fill_between:

    Using fill_between in the following snippet adds an unwanted vertical and horizontal line. Is it because of the parametric equation? How can I fix it?

    import matplotlib.pyplot as plt
    import numpy as np
    t = np.linspace(0, 2 * np.pi, 100)
    x = 16 * np.sin(t)**3
    y = 13 * np.cos(t) - 5 * np.cos(2*t) - 2*np.cos(3*t) - np.cos(4*t)
    plt.plot(x,y, 'red', linewidth=2)
    plt.fill_between(x, y, color = 'red', alpha = 0.2)


    Here is the outcome:

    [​IMG]

    Continue reading...

Compartilhe esta Página