You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong position for 3D Plot with more then one 3D plot in a Grid #413
Wrong position for 3D plot when more than one 3D plot in a grid. All 3D plots are on top of each other at the position of the last 3D plot. 2D plot works. Also if I mix 2D and 3D plots in a grid, all 2D plot are right and the 3D plots have the problem.
Repro steps
#r "nuget: Plotly.NET, 4.2.0"
#r "nuget: Plotly.NET.Interactive, 4.2.0"
#r "nuget: Plotly.NET.CSharp"
using Plotly.NET.CSharp;
var testData = new[]{1.0,1.1,2.0};
var y = testData.Select(s=>s*-1).ToList();
var s1 = Chart.Scatter3D<double, double, double, string>(
x: testData,
y: y,
z: testData.Select(s=>s*1.2).ToList(),
mode: Plotly.NET.StyleParam.Mode.Lines_Markers,
Name: "Plot 1 - 3D"
);
var s2 = Chart.Point<double, double, string>(
x: testData,
y: y,
Name: "Plot 2 - 2D"
);
var s3 = Chart.Scatter3D<double, double, double, string>(
x: testData,
y: y,
z: testData.Select(s=>s*2.1).ToList(),
mode: Plotly.NET.StyleParam.Mode.Lines_Markers,
Name: "Plot 3 - 3D"
);
Chart.Grid(new[]{s1,s2,s3}, 3,1).Show();
Expected behavior
Position of 3D plots should be right
Actual behavior
2D plot works. Also if I mix 2D and 3D plots in a grid, all 2D plot are right and the 3D plots have the problem.
The root of this bug must be the assignment of new scene ids to the existing charts. The internal logic of Chart.Grid combines all charts and adds new unique axis, scene, ternary, etc. positions and ids. Here is the match case for 3D charts:
|> GenericChart.mapTrace (fun t -> t :?> Trace3D |> Trace3DStyle.SetScene sceneAnchor :> Trace)
|> Chart.withScene (scene,(i +1))
so setting a scene id other than 1 here will cause the issue of the contained axis styles not being added to the new scene, the same is true for all other chart types btw. This is by design, checking for any possible scene id (or axis id etc.) adds gigantic overhead to an already very complicated and hard to maintain function.
However, i cannot find striking differences in the code when e.g. comparing with the match case for Ternary traces;
found the underlying issue, there are some fixes necessary that are deep in the low-level APIs, see #415 for details. This will be potentially backwards-incompatible and therefore be in v5.
Activity
kMutagene commentedon Aug 30, 2023
Hey @Nick135, thanks for reporting this. I can confirm this as a regression that seems to occur somewhere between 3.0 and 4.0. It seems to be specific for adding multiple 3D charts to a grid, as a complex example with many different trace types works (see https://plotly.net/chart-layout/multiple-charts.html#Using-subplots-of-different-trace-types-in-a-grid). Adding a second 3D chart breaks the grid in that example.
For now, a quick workaround would be falling back to pre 4.0 versions like this:
Nick135 commentedon Aug 31, 2023
When I add WithXAxisStyle to both 3D Plots, I also get the problem with the v3.0.
bvenn commentedon Aug 31, 2023
Setting unique Axis ids seems to fix this behaviour.
Details
Nick135 commentedon Aug 31, 2023
@bvenn: It looks like it works, but when you see the second 3D Plot, the "TitleText" is not set.
kMutagene commentedon Sep 4, 2023
The root of this bug must be the assignment of new scene ids to the existing charts. The internal logic of
Chart.Gridcombines all charts and adds new unique axis, scene, ternary, etc. positions and ids. Here is the match case for 3D charts:Plotly.NET/src/Plotly.NET/ChartAPI/Chart.fs
Lines 3055 to 3067 in 11456b4
so setting a scene id other than 1 here will cause the issue of the contained axis styles not being added to the new scene, the same is true for all other chart types btw. This is by design, checking for any possible scene id (or axis id etc.) adds gigantic overhead to an already very complicated and hard to maintain function.
However, i cannot find striking differences in the code when e.g. comparing with the match case for Ternary traces;
Plotly.NET/src/Plotly.NET/ChartAPI/Chart.fs
Lines 3133 to 3148 in 11456b4
which works fine:
kMutagene commentedon Sep 4, 2023
I found the core issue in the output at least. The row number for the scenes is incorrect, while it is correct in the ternary example:
with
Chart.Scatter3D:with
Chart.ScatterTernary:which is really weird because at least to my eyes the code looks identical.
kMutagene commentedon Sep 11, 2023
found the underlying issue, there are some fixes necessary that are deep in the low-level APIs, see #415 for details. This will be potentially backwards-incompatible and therefore be in v5.
fix #413: