Search code examples
pythonphysics

Python matplotlib graph, show empty graph


I don't seem to find problem why graph is not showing any lines, its just blank. I am new to python. "Trying to plot graph maximum height and range with angle"

import matplotlib.pyplot as plt
import numpy as np

def projectile(Vo,Angle):
   Acc=9.8
   Mheight=(Vo**2)*np.sin(np.radians(Angle**2))/Acc**2
   Range=(Vo**2)*(np.sin(np.radians(Angle)))/Acc
   plt.plot(int(Mheight),int(Angle)) // This is the line
   plt.show()  // only showing blank graph
   return ("Maximum Height: ",Mheight,"Maximum Range: ",Range)

#Main Function  
Vo=int(input("Enter Velocity: "))
Angle=int(input("Enter Angle: "))
print(projectile(Vo,Angle))

Solution

  • You should give plt.plot() a tuple object.

    thus, like:

        plt.plot((int(Mheight),int(Angle)))
        plt.show() 
    

    by the way, remember the typesetting of your code.