我有这个数组和矩阵:
delta_Array = np.array([0.01,0.02,0.03, 0.04, 0.05, 0.06,0.07, 0.08, 0.09, 0.10])
theta_Matrix =
[[ 0.42860551 0.15916832 -0.11548373 0.21118448 -0.11248666 -0.10941028
0.21753078 0.0066507 ]
[ 0.42860033 0.15916739 -0.11548099 0.2111825 -0.11248553 -0.10940605
0.21752721 0.00665198]
[ 0.42859169 0.15916584 -0.11547644 0.2111792 -0.11248364 -0.109399
0.21752126 0.00665412]
[ 0.4285796 0.15916367 -0.11547007 0.21117458 -0.11248099 -0.10938913
0.21751293 0.00665711]
[ 0.42856405 0.15916088 -0.11546187 0.21116863 -0.11247759 -0.10937644
0.21750223 0.00666096]
[ 0.42854505 0.15915746 -0.11545186 0.21116137 -0.11247344 -0.10936093
0.21748915 0.00666566]
[ 0.4285226 0.15915343 -0.11544002 0.21115279 -0.11246853 -0.1093426
0.2174737 0.00667121]
[ 0.4284967 0.15914878 -0.11542637 0.21114289 -0.11246286 -0.10932146
0.21745587 0.00667762]
[ 0.42846735 0.15914351 -0.1154109 0.21113166 -0.11245644 -0.1092975
0.21743567 0.00668487]
[ 0.42843455 0.15913762 -0.11539361 0.21111912 -0.11244926 -0.10927074
0.2174131 0.00669298]]
theta_matrix的每一列都是1种颜色。 delta_array的每个元素都给出了theta_matrix中的相应行。我意识到,为了获得这些曲线,我需要更多的delta值。但是现在我只是使用一个小输入
然而,我的这段代码
figure(1)
plot(delta_Array, theta_Matrix)
plt.show()
绘制如下图:
显然我错过了许多作品。我从这里学到了这些基本的东西:
http://courses.csail.mit.edu/6.867/wiki/images/3/3f/Plot-python.pdf
但我试图填补缺失的部分。任何人都可以帮我一把吗? 我是新手,所以如果你知道一些简单的教程我会很感激。不幸的是,大多数在线教程都比我有更高的熟练程度。
由于
答案 0 :(得分:0)
您的问题和数据不明确,但请尝试以下方法:
import numpy as np
import matplotlib.pyplot as plt
delta_Array = np.array([0.01,0.02,0.03, 0.04, 0.05,
0.06,0.07, 0.08, 0.09, 0.10])
#Initialized to 0s. Actual values will be appended to matrix by function
theta_Matrix = np.random.random() * np.random.rand(delta_Array.size, 8)
fig = plt.figure()
p1 = plt.plot(delta_Array, theta_Matrix)
# make a legend for both plots
leg = plt.legend(p1, '', loc=1)
plt.show()
答案 1 :(得分:0)
当您更新矩阵时,问题在于数据的长度和组织。
首先更改x数据的长度:
delta_Array = np.array([0.01,0.02,0.03, 0.04, 0.05,
0.06,0.07, 0.08])
然后转置你的矩阵:
p1 = plt.plot(delta_Array, ThetaMatrix.T)