I have a matrix X
contains only 1 row that serves as an input. I have a matrix Y
of which each row serves as an output of a function. If Y
has 5 rows, then we have 5 different functions. I plot all functions on the same graph with the following code:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
Y = np.random.randint(1, 9, size = (5, 7))
X = np.arange(- 3, 4)
fig, ax = plt.subplots()
for i in range(5):
ax.plot(X, Y[i])
and its result
I would like ask how to add the legend of this graph. My desire format is
n = 0: color 0
n = 1: color 1
n = 2: color 2
n = 3: color 3
n = 4: color 4
n = 5: color 5
Thank you so much for your help!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.