首页 > 解决方案 > PlotlyJS 3d 锥体

问题描述

我在其中使用 Julia 和 PlotlyJS,通过在 3d 图中使用锥形轨迹来绘制一些速度场图。

有没有办法通过数字列表(长度=#cones)设置锥体的大小?

代码:

function plot_av(res::DataFrame, n::Int)
    """
    Function to plot the average velocity field

    Inputs:
       - res:: Dataframe for cells properties
       - n:: minimum number of stars in cell
    """

    res_full = res[res[:n_star] .> n-1, :]

    # Galactic Centre

    t0 = scatter3d(; x = [0], y = [0], z = [0], mode = "markers",
                 marker = attr(color = "#000000", 
                 size = 4, symbol = "cross", opacity = 1), 
                 name = "Galactic Center")


     # Average speed; 
     fields = Dict{Symbol,Any}(:type => "cone",
                      :x => collect(res_full[:x_cell]),
                      :y => collect(res_full[:y_cell]),
                      :z => collect(res_full[:z_cell]),
                      :u => collect(res_full[:u_mean]),
                      :v => collect(res_full[:v_mean]),
                      :w => collect(res_full[:w_mean]),
                      :sizemode => "absolute",
                      :sizeref => 100,
                      :colorscale => "Greens"
      )

     tvel = GenericTrace("cone", fields)

     layout = Layout(autosize=false, width=800, height=800, 
     margin=attr(l=0, r=0, b=0, t=65))

     plot([t0, tvel], layout)
end

我尝试设置:sizeref为一个数组,但它不起作用。

标签: juliaplotly

解决方案


:sizeref 由 Plotly 例程使用,这里有源代码: https ://github.com/plotly/plotly.js/blob/master/src/traces/cone/attributes.js

这似乎被定义并用作单个数字。所以这个限制似乎是 Plotly 中的一个。所以,我认为 PlotlyJS 不能在这里使用数组。


推荐阅读