Home > Enterprise >  Plotting multiple y-values versus x using Matplotlib
Plotting multiple y-values versus x using Matplotlib

Time:09-21

I am trying to plot y1,y2,y3 all as a function of x and show all the three on a single plot. But it is showing only two plots. I present the current output.

import matplotlib.pyplot as plt
import numpy as np
x=np.linspace(-1,0,10)
print(x)
y1=36.554 5.418*np.exp(-1.327*x) 
y2=23.816 18.088*np.exp(-0.812*x)
y3=20.562 21.389*np.exp(-0.765*x)
print(y1,y2,y3)
plt.plot(x,y1,y2,y3)

The current output is

Output

CodePudding user response:

Try this:

plt.plot(x, y1, x, y2, x, y3)
  • Related