Q. Given two ndarrays. Write a program to plot them in the same line graph and show legends.
Answer :-
import matplotlib.pyplot as plt import numpy as np x = np.arange (0,10) y = np.random.randint (10, size = (10,)) z = np.random.randint (50, size = (10,)) plt.figure (figsize = (8,4)) plt.plot(x, y, label = "Y data") plt.plot(x, z, label = "Z data") plt.legend (loc = "upper left") plt.show()
Output :-
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )