how to plot multiple functions in the same plot
Question:
How can I plot the following functions?
Answers:
You can use matplotlib
to plot multiple functions on the same graph, there are several ways of achieving this.
One of the easiest ways is as shown
import matplotlib.pyplot as plt
import numpy as np
# I will make up sample values of t
t = np.arange(1, 30, 2) # [1, 3, 5, ..29 1 to 29 increment by 2
A = 6 / ( 4+ t ** 2) # function 1
B = 6 / ( 4 + t ** 3) # function 2
C = 18/( 3 * t) # making up random function here as function 3
# red dashes, blue squares and green triangles
# think of this as (x, y , color/symbols)
plt.plot(t, A, 'r--', t, B, 'bs', t, C, 'g^')
plt.show()
How can I plot the following functions?
You can use matplotlib
to plot multiple functions on the same graph, there are several ways of achieving this.
One of the easiest ways is as shown
import matplotlib.pyplot as plt
import numpy as np
# I will make up sample values of t
t = np.arange(1, 30, 2) # [1, 3, 5, ..29 1 to 29 increment by 2
A = 6 / ( 4+ t ** 2) # function 1
B = 6 / ( 4 + t ** 3) # function 2
C = 18/( 3 * t) # making up random function here as function 3
# red dashes, blue squares and green triangles
# think of this as (x, y , color/symbols)
plt.plot(t, A, 'r--', t, B, 'bs', t, C, 'g^')
plt.show()