Thanks @AIMPED. Unfortunately, the Julia documentation for Plotly is a little sketchy–good but basic introduction on juliaplots.org but on Plotly julia graphing library in Julia, incomplete (various To-Do’s), sentence fragments, some docs in JavaScript syntax, 404 links, etc. I am a Julia learner and Python learner, and a Plotly learner. There is nowhere any documentation on the Julia function update_scenes!. So with your suggestion I fell back to reading some of the Python docs.
Since my original post, I have found problems other than the entire layout of indivicual plots being ignored when passed to make subplots. I suspect this is a Plotly design principle and not a Python or Julia problem.
I have shifted my focus to using make_subplots
so that I can better understand what is going on and why I can’t get the plots I want, which are surface subplots. I have focused on a single parameter, the scene_camera_projection_type
.
From a new Julia session, I run this code:
using PlotlyJS
x = collect(range(-15, stop=15, length=3))
y = collect(range(-15, stop=15, length=3))
xGrid, yGrid = mgrid(y, x)
z_1 = xGrid.^2 + yGrid.^2
z_2 = abs.(sin.(xGrid / 3.0) + sin.(yGrid / 3.0))
fig = make_subplots(rows = 1, cols = 2,
specs = [Spec(kind = "scene") Spec(kind = "scene")])
add_trace!(fig, surface(;x=x, y=y, z=z_1), row = 1, col = 1)
add_trace!(fig, surface(;x=x, y=y, z=z_2), row = 1, col = 2)
update_scenes!(fig, scene_camera_projection_type = "perspective",
row = 1, col = 1)
update_scenes!(fig, scene2_camera_projection_type="orthographic",
row = 1, col = 2)
display(fig)
Then I investigate the layout dictionary for fig like this:
println(fig.plot.layout[:scene])
Dict{Any, Any}(:row => 1, :scene => Dict{Any, Any}(:camera => Dict{Any, Any}(:projection => Dict{Any, Any}(:type => "perspective"))), :domain => Dict{Any, Any}(:y => (0.0, 1.0), :x => (0.0, 0.45)), :col => 2, :scene2 => Dict{Any, Any}(:camera => Dict{Any, Any}(:projection => Dict{Any, Any}(:type => "orthographic"))))
and then these four lines:
julia> println(fig.plot.layout[:scene][:scene][:camera][:projection][:type])
perspective
julia> println(fig.plot.layout[:scene][:scene2][:camera][:projection][:type])
orthographic
julia> println(fig.plot.layout[:scene2][:scene][:camera][:projection][:type])
perspective
julia> println(fig.plot.layout[:scene2][:scene2][:camera][:projection][:type])
orthographic
Both plots display as “perspective”.
Why are there two scenes, each with their own two scenes?
So then I tried assigning directly to scene2 scene like this:
fig.plot.layout[:scene2][:scene][:camera][:projection][:type] = "orthographic"
fig
Both plots still display as “perspective”.
Let’s re-do the prevoius queries:
julia> println(fig.plot.layout[:scene][:scene][:camera][:projection][:type])
orthographic
julia> println(fig.plot.layout[:scene][:scene2][:camera][:projection][:type])
orthographic
julia> println(fig.plot.layout[:scene2][:scene][:camera][:projection][:type])
orthographic
julia> println(fig.plot.layout[:scene2][:scene2][:camera][:projection][:type])
orthographic
I have spent an embarrassing amount of time getting to this point and now I feel stuck.
Any ideas?