我運行Python代碼,因爲它是從本網站:pylab.show()沒有工作
http://cvxopt.org/examples/book/rls.html
要在這裏表現出來:
# Figure 4.11, page 185.
# Regularized least-squares.
....
pylab.figure(1, facecolor='w')
pylab.plot(lbnds, alpha1, 'b-', ubnds, alpha2, 'b-')
kmax = max([ k for k in range(len(alpha1)) if alpha1[k] <
blas.nrm2(xls)**2 ])
pylab.plot([ blas.nrm2(b)**2 ] + lbnds[:kmax] +
[ blas.nrm2(A*xls-b)**2 ], [0.0] + alpha1[:kmax] +
[ blas.nrm2(xls)**2 ], '-', linewidth=2)
pylab.plot([ blas.nrm2(b)**2, blas.nrm2(A*xls-b)**2 ],
[0.0, blas.nrm2(xls)**2], 'bo')
pylab.fill(lbnds[-1::-1] + ubnds + [ubnds[-1]],
alpha1[-1::-1] + alpha2+ [alpha1[-1]], facecolor = '#D0D0D0')
pylab.axis([0, 15, -1.0, 15])
pylab.xlabel('||A*x-b||_2^2')
pylab.ylabel('||x||_2^2')
pylab.grid()
pylab.title('Regularized least-squares (fig. 4.11)')
pylab.show()
它應該顯示我運行python rls.py
後繪圖。但沒有出現,有任何幫助?謝謝
什麼後端您使用的似乎好? – tacaswell
我用的是Mac ....... –
該頁面上的代碼有「try:import pylab」。也許刪除「嘗試」,以確保它實際上已成功導入pylab ... – DanHickstein