Python 在matplotlib中将行向量表示为线图

Python 在matplotlib中将行向量表示为线图,python,matplotlib,Python,Matplotlib,假设我有一个形状为1100的行向量。叫它罗 我想在线形图中显示其值。x轴显示矢量索引。y轴显示相应索引处的值。您将如何在matplotlib中执行此操作 编辑: 以下是我尝试过的: indices = [n for n in range(100)] values = list(row[:, :100]) pyplot.plot(indices, values) 数组索引不是必需的。 值数组语法不清楚。。。以及python中的一个错误,除非您使用的是numpy 下面将绘制一个随机值数组,索引为x

假设我有一个形状为1100的行向量。叫它罗

我想在线形图中显示其值。x轴显示矢量索引。y轴显示相应索引处的值。您将如何在matplotlib中执行此操作

编辑:

以下是我尝试过的:

indices = [n for n in range(100)]
values = list(row[:, :100])
pyplot.plot(indices, values)
数组索引不是必需的。 值数组语法不清楚。。。以及python中的一个错误,除非您使用的是numpy

下面将绘制一个随机值数组,索引为x,值中存储的随机数为y


请发布您尝试过的代码?
import matplotlib.pyplot as plt
import random

# indices = [n for n in range(100)]
values = [random.random() for _ in range(100)]
plt.plot(values)
plt.show()
  import matplotlib.pyplot as plt

    indices = range(100) # already returns a list, no need to iterate again
    values = # insert 1d vector here, what you seem to use is multi-dim
    plt.plot(indices, values)
    plt.show()