how to plot multiple functions in the same plot

Question:

How can I plot the following functions?

functions

Asked By: tatatoubouma

||

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()

You should have something like this
enter image description here

Answered By: Ibukun Muyide
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.