Force scale ratio if x and y axis have same unit for 1D and 2D plots#80
Force scale ratio if x and y axis have same unit for 1D and 2D plots#80mfiaudrin-epsyl wants to merge 4 commits into
Conversation
Documentation build overview
48 files changed ·
|
There was a problem hiding this comment.
Pull request overview
Adds automatic 1:1 axis scaling for 1D and 2D plots when the relevant axes share the same unit, improving visual comparability for same-unit data.
Changes:
- SimplePlotly: compute a
shouldForceRatiorule and apply Plotlyxaxis.scaleanchor/scaleratioaccordingly. - Heatmap2D: compute a similar
shouldForceRatiorule from coordinate units and apply the same Plotly layout constraint.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| frontend/src/renderer/components/plot/SimplePlotly.tsx | Adds a same-unit detection rule and conditionally anchors x/y scaling via Plotly layout. |
| frontend/src/renderer/components/plot/Heatmap2D.tsx | Adds a coordinate-unit equality rule and conditionally anchors x/y scaling via Plotly layout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Errors encountered when testing this PR are described in #84 (it also affects the Otherwise the square ratio feature works as expected. From our last discussion with the group and @imbeauf, we mentioned that ideally there would be a customization option to allow the user to disable the fixed ratio (fix ratio is good as the default behavior), as well as to enable fixed ratio even if units are not the same in x and y. |
|
I hadn't planned on including ratio customization in this PR, but I've made good progress on the geometry overlay feature, so I'll add it to this PR. I'm marking it as DRAFT until it's implemented. |
|
@olivhoenen I've just added the axis ratios rule in visual customization / global. Copilot's comments were also taken into account. The PR is ready for review. |
| isTitleOverwritten: boolean; | ||
| displayErrorBand: boolean; | ||
| displayGrid: boolean; | ||
| xyRatioRule: 'Auto' | 'None' | 'Force'; |
There was a problem hiding this comment.
Drop-down menu with these 3 options does not feel like the most friendly UI.
A simple boolean would be preferred here in the customization its square ratio or not. Auto shall just correspond of the value of this boolean while plotting the data for the first time.
There was a problem hiding this comment.
As during our discussion this morning it was raised that these three modes were present because they apply also in 1D plots and when we switch back and forth between 2D and 1D, maybe we can simplify and only have this costumisation option for 2D plots?
That way this option has no effect on 1D plots, where fixed ratio between x and y ticks is less of an issue.
The initial value of this boolean is decided with the first plot (if units are the same then it toggles fixed ratio for 2D) and latter impact further 2D plots in the same figure until the user customize the plot. On the other hand, if a first 2D plot has different units (like [s] vs [m]) then fixed ratio won't be forced in the figure, and could later be custonized by user.
If this (default value of the boolean depending on units of the first 2D plot in the figure) we can also decide to simplify and set a static default value (e.g. fixed ratio, so spatial planes will look nicer) and let the user unselect the option if she/he wants a plot that covers the entire figure.
For further reference and additional context, please see how this is handled in h5view with this small video:
myhdf5-ratio-2026-06-12_11.36.57.mp4
There was a problem hiding this comment.
Thank you for your the proposed solution. I agree that if we apply the square ratio only for 2D plots, it will simplify the use of a boolean instead.
We just need to improve the solution to be compatible with the feature allowing to change of axis. In this case, units of x & y axis can change. So I am wondering what we should do.
I see 2 possibilities:
- When adding a new dataGrid, we initialise the square ratio boolean (true or false depending x & y units). No matter if we change of axis later, we will keep the square ratio as it was at the initialisation
- Or we update the square ratio boolean each time we update axis. So, in case the user has forced to keep ratio to true for instance, it will overwrite the keep ratio value by applying the unit rule each time we change of axis
Which one do you think will be the most appropriate for the users ?
From my point of view, I think the second option will be better because by changing axis, we always ensure the user have the expected ratio for visualisation. And then, it's up to him to update the ratio.
This feature add a rule to display the plots with the the same ratio between x & y axis if they have the same unit.
It also Closes #71