如何在julia中使用colorbar绘制imagesc样式热图

Jen*_*ise 8 julia

这是我试过的.

- Winston软件包:在尝试安装或使用时会出现许多错误,说"语法已弃用".我尝试过做Pkg.update(),但这并不能解决我的错误.尽管有错误,但Winston会使用imagesc函数绘制热图,就像matlab一样......太棒了!但温斯顿没有色条(?):(

- Plotly包:在尝试安装或使用时也会出现许多错误,说"语法已弃用".我尝试过做Pkg.update(),但这并不能解决我的错误.Plotly在其文档中显示它有彩色条,但我无法正常工作,可能是因为语法问题已被弃用.

非常感谢JULIA绘制图像风格热图的任何建议!我无法访问matlab.

Dav*_*ers 8

PyPlot 是一个很好的选择:

using PyPlot

M = rand(10, 10)
pcolormesh(M)
colorbar()
Run Code Online (Sandbox Code Playgroud)

[ pcolor代表"伪彩色".是的,这是一个可怕的名字.是的,它确实来自MATLAB,就像许多其他可怕的名字一样......]

有三种不同的相关功能:pcolor,pcolormesh并且imshow,它们具有不同的可能性; 请参阅Matplotlib文档,例如http://matplotlib.org/examples/pylab_examples/pcolor_demo.html (请注意,Julia中的语法可能略有不同.)

Plots.jl包(https://github.com/tbreloff/Plots.jl)具有heatmap与几个不同的后端工作的功能.在我看来,这是朱莉娅策划的未来,因为你不必学习不同包装的复杂性.

编辑:确实实现了彩条Plots.jl!请参阅此问题:https://github.com/tbreloff/Plots.jl/issues/52


Ran*_*tch 5

您可以尝试Vega.jl包.我最近构建了一个热图功能的存根.该示例适用于julia 0.4+,但如果您有任何问题,请提出问题.我经常更新包.

http://johnmyleswhite.github.io/Vega.jl/heatmap.html

Pkg.add("Vega")
using Vega

x = Array(Int, 900)
y = Array(Int, 900)
color = Array(Float64, 900)

t = 0
for i in 1:30
    for j in 1:30
        t += 1
        x[t] = i
        y[t] = j
        color[t] = rand()
    end
end

hm = heatmap(x = x, y = y, color = color)
Run Code Online (Sandbox Code Playgroud)