pylab.show()无效

时间:2016-04-29 01:01:24

标签: python matplotlib

我从这个网站运行python代码:

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后显示情节。但没有任何出现,任何帮助?谢谢

2 个答案:

答案 0 :(得分:0)

使用# Use <C-a> instead of the default <C-b> as Tmux prefix set-option -g prefix C-a unbind-key C-b bind-key C-a send-prefix # This option with vim set term=xterm-256color allow CTRL mappings set-option -gw xterm-keys on # Options to enable mouse support in Tmux set -g terminal-overrides 'xterm*:smcup@:rmcup@' # For Tmux >= 2.1 set -g mouse on # Escape time for libtermkey # (see https://github.com/neovim/neovim/issues/2035): set -sg escape-time 10 # Act more like vi: set-window-option -g mode-keys vi bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R unbind p bind p paste-buffer bind -t vi-copy v begin-selection bind -t vi-copy y copy-selection 时,您需要启用交互式后端以获取绘图查看器窗口。 'agg'背景是非交互式的(虽然有基于Agg的交互式后端,例如TkAgg,Qt5Agg)。

您有几个选项,但MacOS X最简单的选项是'macosx'后端。您可以使用脚本顶部的以下内容启用此功能:

pylab.show()

答案 1 :(得分:0)

我只是干净的重新安装,现在看起来很不错

http://matplotlib.org/faq/installing_faq.html