我正在尝试使用spy()。但我没有正确使用它。我认为我的错误与此有关:https://github.com/JuliaLang/julia/issues/2121
我有一个300x300阵列{Float64,2}
using PyPlot
pygui(true)
spy(I) # where I is my 300x300 array
它给了我这个错误:
LoadError: PyError (:PyObject_Call) <type 'exceptions.TypeError'>
TypeError("object of type 'PyCall.jlwrap' has no len()",)
File "/home/ashley/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py", line 3154, in plot
ret = ax.plot(*args, **kwargs)
File "/home/ashley/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 1539, in plot
zs = np.ones(len(xs)) * zs
我已尝试指定spy(I, zs=zeros(size(I))
,但之后我收到错误:
LoadError: ArgumentError: function spy does not accept keyword arguments
while loading In[260], in expression starting on line 13
有什么想法吗?
答案 0 :(得分:1)
spy
显示非零元素。显然,如果没有非零元素,它就不会显示任何内容。
M = sprand(300, 300, 0.1) # generate a sparse matrix with density 0.1 of non-zeros
M = full(M)
spy(M)
适合我。