【发布时间】:2021-04-20 10:55:16
【问题描述】:
我有一个矩阵列表。我想在另一个列表的函数中绘制这些矩阵的每个元素。
但是我在不使用循环的情况下努力做到这一点。
我怎样才能以最简单的方式做到这一点?
下面的代码解释了我想要做什么。
import numpy as np
from numpy import *
from matplotlib.pyplot import *
import matplotlib.pyplot as plt
from mpmath import *
import mpmath as mpmath
import pylab
import numpy
import time
import math
from qutip.sparse import sp_eigs
import numpy, scipy.io
from random import *
randomMatrixList=[np.random.rand(2,2) for _ in range(10)]
index=np.arange(10)
# I want to plot on x axis: index, on y axis: randomMatrixList[ii][0] for ii
# corresponding to index[ii] for the "0" curve, then randomMatrixList[ii][1] for the first one, and so on
【问题讨论】:
-
请删除所有不必要的代码。大多数导入都不需要(例如
time、pylab等)。
标签: python list numpy matplotlib