9951 explained code solutions for 126 technologies


python-matplotlibHow to plot Numpy data


We cam pass Numpy arrays directly to plot() method:

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-5, 15, 50)

plt.plot(x, x**2)

plt.show()ctrl + c
import numpy as np

load Numpy module for Python

import matplotlib.pyplot as plt

loads Matplotlib module to use plotting capabilities

np.linspace

generate random values based on specified range and count

.plot(

plot specified data

.show()

render chart in a separate window