[英]How to plot the legend of this graph of which there are many functions?
I have a matrix X
contains only 1 row that serves as an input.我有一个矩阵
X
只包含 1 行作为输入。 I have a matrix Y
of which each row serves as an output of a function.我有一个矩阵
Y
,其中每一行用作 function 的 output。 If Y
has 5 rows, then we have 5 different functions.如果
Y
有 5 行,那么我们有 5 个不同的函数。 I plot all functions on the same graph with the following code:我 plot 使用以下代码在同一图表上的所有功能:
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!非常感谢你的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.