How to: Plot a Function in Python
Learn how to define a function and plot it in Python.
Script can be found here: https://www.hageslab.com/python.html
Here we are using "Spyder" IDE with the numpy and matplotlib libraries
Useful resources:
https://matplotlib.org/tutorials/text/mathtext.html
https://matplotlib.org/
https://matplotlib.org/3.3.3/api/_as_gen/matplotlib.pyplot.plot.html#matplotlib.pyplot.plot
Script:
import numpy as np
import matplotlib.pyplot as plt
def f(x,a,b,c):
return a*x**2+b*x+c
xlist = np.linspace(-10,10,num=1000)
# xlist = np.arange(-10,10.1,.1)
a=5
b=1
c=4
ylist = f(xlist,a,b,c)
plt.figure(num=0,dpi=120)
plt.plot(xlist,ylist,label="f(x)")
plt.plot(xlist,ylist**(1/2),'--g',label=r"f(x)$^{0.5}$")
plt.title("Plotting Example")
plt.xlabel("Distance / ft")
plt.ylabel("Height / ft")
plt.legend()
Видео How to: Plot a Function in Python канала HagesLab
Script can be found here: https://www.hageslab.com/python.html
Here we are using "Spyder" IDE with the numpy and matplotlib libraries
Useful resources:
https://matplotlib.org/tutorials/text/mathtext.html
https://matplotlib.org/
https://matplotlib.org/3.3.3/api/_as_gen/matplotlib.pyplot.plot.html#matplotlib.pyplot.plot
Script:
import numpy as np
import matplotlib.pyplot as plt
def f(x,a,b,c):
return a*x**2+b*x+c
xlist = np.linspace(-10,10,num=1000)
# xlist = np.arange(-10,10.1,.1)
a=5
b=1
c=4
ylist = f(xlist,a,b,c)
plt.figure(num=0,dpi=120)
plt.plot(xlist,ylist,label="f(x)")
plt.plot(xlist,ylist**(1/2),'--g',label=r"f(x)$^{0.5}$")
plt.title("Plotting Example")
plt.xlabel("Distance / ft")
plt.ylabel("Height / ft")
plt.legend()
Видео How to: Plot a Function in Python канала HagesLab
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
How to: Import, Plot, Fit, and Integrate Data in PythonIntro to Data Analysis / Visualization with Python, Matplotlib and Pandas | Matplotlib TutorialPython Django Web Framework - Full Course for BeginnersAll Top 40 Python Libraries EXPLAINED in 20 minutesUsing My Python Skills To Punish Credit Card ScammersWhy Python is huge in finance? by Daniel RoosRaspberry Pi show real time sensor data in a graph PythonPython Video 07d: Plotting Contour and Surface Plots with MatplotlibPython Tutorial for Beginners - Learn Python in 1 HourHow I taught myself to code | Litha Soyizwapi | TEDxSowetoHow to: Numerical Derivative in PythonMatplotlib Tutorial (Part 1): Creating and Customizing Our First PlotsSolving real world data science tasks with Python Pandas!5 Things You're Doing Wrong When Programming in PythonIntro to Plotting with PythonNon-Linear CURVE FITTING using PYTHONMATPLOTLIB - Les Bases ! (14/30)Navigation - Chart Navigation (Chart Plotting Part 1)Matplotlib Crash CourseWhy Most People FAIL to Learn Programming