KnowledgeBoat Logo
|
LoginJOIN NOW

Informatics Practices

Write a Python program to plot the function y = x2 using the Matplotlib library.

PyPlot

1 Like

Answer

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(1, 5)
y = x ** 2
plt.plot(x, y)

plt.title('Line Graph of y = x²')
plt.xlabel('x')
plt.ylabel('y')

plt.show()
Output
Write a Python program to plot the function y = x^2 using the Matplotlib library. Data Visualization using Matplotlib, Informatics Practices Preeti Arora Solutions CBSE Class 12

Answered By

3 Likes


Related Questions