Z component of scene_camera_eye not being passed to subplots

When making subplots using the basic “matrix pun” method, the layout parameter for the z part of scene_camera_eye, which is set up for the individual plots, is not passed to the same plots when they are made part of a subplot. This also happens with other Layout parameters, such as when adding

scene_camera_projection = attr(type = "orthographic")

to the parameters for a layout.

Also, the button for “Reset Camera to Last Save” fails for the subplots, having the same effect as the button “Reset Camera to default.”

The following example sets up a simple layout, displays each of two plots separately, then displays them together as subplots. Note how the vertical aspect has changed.

I am using Visual Studio Code 1.74.1 on macOS 12.6.5, Julia version 1.8.2, and Plotly version 0.18.10

How do I make the plots have the same z view when displayed as subplots as they had when displayed separately?

using PlotlyJS
layout = Layout(scene_camera_eye = attr(x = -1.6, y = -1.6, z = 0.0),
    scene_aspectmode = "cube")
x = collect(range(-15, stop=15, length=100))
y = collect(range(-15, stop=15, length=100))
xGrid, yGrid = mgrid(y, x)
z_1 = xGrid.^2 + yGrid.^2
z_2 = abs.(sin.(xGrid / 3.0) + sin.(yGrid / 3.0))
Plot_1 = plot(surface(x=x, y=y, z=z_1), layout)
Plot_2 = plot(surface(x=x, y=y, z=z_2), layout)
display(Plot_1)
display(Plot_2)
Plot_Both = [Plot_1 Plot_2]
display(Plot_Both)

HI @oscar, not sure how this is implemented in Julia, but in Python you can do this changing each scene. There should be something similar.

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?

OP. It’s probably best to discontinue this discussion since I have now clarified the problem and posted a ticekt at Subplot scene attributes are overwritten by another scene's attributes.