首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Makie.jl中的绘图属性

Makie.jl中的绘图属性
EN

Stack Overflow用户
提问于 2021-08-06 04:49:19
回答 1查看 529关注 0票数 1

我想用HeatMap在xyz空间中画一个函数f(x,y,z)。

下面是https://lazarusa.github.io/BeautifulMakie/surfWireLines/RGBcube/编写的代码。

代码语言:javascript
复制
using GLMakie, GeometryBasics, Colors

positions = vec([(i, j, k) for i=1:L,j=1:L,k=1:L]) #3D coordinate
F = zeros(Float64,length(positions)

for i = 1:length(positions) #convert f(x,y,z) to an array
  x = positions[i][1]
  y = positions[i][2]
  z = positions[i][3]
   F[i] = f(x,y,z)
end
代码语言:javascript
复制
fig, ax = mesh(HyperRectangle(Vec3f0(positions[1]...),Vec3f0(0.8)), color = RGBA(0,0,F[1],0.5), transparency = false) #HyperRectangle(::position,::length),color=(::red,::green,::blue,::alpha)
wireframe!(ax,HyperRectangle(Vec3f0(positions[1]...), Vec3f0(0.8)), linewidth = 0.1, overdraw = false)

for i in 2:length(positions)
  mesh!(ax, HyperRectangle(Vec3f0(positions[i]...), Vec3f0(0.8)), color = RGBA(0,0,F[i],0.5))
  wireframe!(ax, HyperRectangle(Vec3f0(positions[i]...), Vec3f0(0.8)), linewidth = 0.1, overdraw = false)
end

fig

这段代码起到了很大的作用,但仍然存在一些小问题。

  1. 如何移动照相机?(update_camera!需要Scene,但axLScene。我不知道这是什么)
  2. 如何调整轴线(标签、滴答等)?
  3. 如何添加
  4. 以保存数字?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-08 14:04:22

再来一次。我做了另一个例子。这个真快。在那里,你有你想要的大部分选择。

https://lazarusa.github.io/BeautifulMakie/surfWireLines/volumeScatters/

对于定制的蜱类,您可以始终这样做。

代码语言:javascript
复制
ax.xticks = ([1,2,3], ["1","2", "3"])

另外,考虑一下加入https://discourse.julialang.org,那里有更多的人可以帮助,要快得多。

这里也有完整的代码。

代码语言:javascript
复制
# by Lazaro Alonso
using GLMakie
let
    x = 1:10
    y = 1:10
    z = 1:10
    f(x,y,z) = x^2 + y^2 + z^2
    positions = vec([(i, j, k) for i in x,j in y, k in z])
    vals = [f(ix,iy,iz) for ix in x, iy in y, iz in z]
    fig, ax, pltobj = meshscatter(positions, color = vec(vals), 
        marker = FRect3D(Vec3f0(0), Vec3f0(10)), # here, if you use less than 10, you will see smaller squares. 
        colormap = :Spectral_11, colorrange = (minimum(vals), maximum(vals)), 
        transparency = true, # set to false, if you don't want the transparency. 
        shading= false, 
        figure = (; resolution = (800,800)),  
        axis=(; type=Axis3, perspectiveness = 0.5,  azimuth = 7.19, elevation = 0.57,  
            xlabel = "x label", ylabel = "y label", zlabel = "z label",
            aspect = (1,1,1)))
    cbar = Colorbar(fig, pltobj, label = "f values", height = Relative(0.5))
    xlims!(ax,-1,11)
    ylims!(ax,-1,11)
    zlims!(ax,-1,11)
    fig[1,2] = cbar
    fig
    #save("fileName.png", fig) # here, you save your figure. 
end
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68676269

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档