[Python] Why aren't my Lists recording onto my Graph (or at all)?

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    So I'm making code that supposed to track how the distance of an object impacts the force it makes, yet for some reason, my list function will only record my last value input into the While loop. In addition, the graph won't even show that value. Im using Matplotlib and SymPy, nothing really extreme for packages. Can someone please help me with these two issues?

    import sympy as sy
    sy.init_printing()
    from sympy import *
    import matplotlib.pyplot as plt

    x=1

    print('Give it a minute please')

    List_p = list()
    List_x = list()

    while x<=750:
    theta = atan(400/x)
    Fd=10*500*cos(theta)/(x/cos(theta))
    p=Fd*sin(theta)
    List_p.append(p)
    List_x.append(x)
    x=x+1

    plt.plot([x],[p])
    plt.xlim(1,750)
    plt.xlabel('Distance')
    plt.ylabel('Force of P')
    plt.title('Distance V Force of P')
    plt.show()

    Continue reading...

Compartilhe esta Página