Plotting Multiple Expressions in One Graph in Python
Author: David Manuel
In this video, we learn how to plot multiple expressions on the same graph in Python, which allows us to plot piecewise functions. The presenter also shows how to use different colors for each part of the graph so we can distinguish them.
Transcript 06
Transcript 06
Exercises
Python Code:
from sympy import *
matplotlib notebook
x=symbols('x')
f1=2*x+6
f2=x**2
plotf=plot((f1,(x,-5,-2)),(f2,(x,-2,3)),show=False)
plotf[1].line_color='red'
plotf.show()
Open Python Notebook File
from sympy import *
matplotlib notebook
x=symbols('x')
f1=2*x+6
f2=x**2
plotf=plot((f1,(x,-5,-2)),(f2,(x,-2,3)),show=False)
plotf[1].line_color='red'
plotf.show()
Open Python Notebook File
