Thursday, October 17, 2019

Python: Plotting graphs

Plot  graph g(t) = (t^2, t^3 - t) for t(-2,2)

import matplotlib.pyplot as mp
import numpy as np
#Domain
t = np.arange(-2,2,0.001)
# create lists x and y which have all the values of x and y for the given domain
x = []
y = []

for i in t:
  x = x + [i*i]
  y = y + [i*i*i -3*i]
mp.plot(x, y)
  #mp.show()

# naming the x axis
mp.xlabel('x - axis')
# naming the y axis
mp.ylabel('y - axis')

# giving a title to my graph
mp.title('')

# function to show the plot
mp.show()

Output:
You can practice python at colab


No comments:

Post a Comment

Derivatives stock list at NSE

Complete FNO stock list at NSE. ABB India Ltd ACC Ltd APL Apollo Tubes Ltd AU Small Finance Bank Ltd Aarti Industries Ltd Abbott India Ltd A...