Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve model and transform_func interaction with Axis limits #3864

Merged
merged 14 commits into from
May 16, 2024

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented May 13, 2024

Description

This is an attempt at resolving issues with model transformations (scale!, translate!) in Axis with or without tranform_func by relying on boundingbox instead of data_limits and undoing the transform_func afterwards. My gut feeling is that this will result in domain errors for some transformations in some situations...

This should fix #3562 and similar issues.

Based on #3856 since there are some overlapping issues (hexbin typo, model application with NaN)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Added an entry in CHANGELOG.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@MakieBot
Copy link
Collaborator

MakieBot commented May 13, 2024

Compile Times benchmark

Note, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running:

using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(fig)
using create display create display
GLMakie 4.23s (4.18, 4.26) 0.02+- 106.26ms (104.73, 108.94) 1.65+- 478.77ms (469.90, 486.16) 6.37+- 7.63ms (7.45, 7.79) 0.13+- 25.50ms (25.38, 25.65) 0.10+-
master 4.21s (4.17, 4.29) 0.04+- 104.92ms (103.60, 107.53) 1.31+- 475.85ms (471.75, 483.65) 4.29+- 7.75ms (7.63, 7.95) 0.11+- 25.71ms (25.39, 26.04) 0.20+-
evaluation 1.00x invariant, 0.01s (0.46d, 0.41p, 0.03std) 0.99x invariant, 1.33ms (0.89d, 0.12p, 1.48std) 0.99x invariant, 2.92ms (0.54d, 0.34p, 5.33std) 1.02x invariant, -0.13ms (-1.08d, 0.07p, 0.12std) 1.01x faster ✓, -0.21ms (-1.33d, 0.04p, 0.15std)
CairoMakie 3.64s (3.59, 3.69) 0.03+- 106.41ms (104.14, 108.77) 1.47+- 130.77ms (126.89, 134.33) 2.36+- 7.62ms (7.55, 7.76) 0.07+- 976.29μs (969.34, 997.49) 10.00+-
master 3.80s (3.75, 3.90) 0.05+- 104.41ms (102.64, 109.98) 2.59+- 129.52ms (126.58, 134.37) 2.94+- 7.69ms (7.52, 7.90) 0.14+- 975.58μs (962.41, 1009.77) 16.30+-
evaluation 1.04x faster ✓, -0.16s (-3.59d, 0.00p, 0.04std) 0.98x invariant, 2.0ms (0.95d, 0.11p, 2.03std) 0.99x invariant, 1.25ms (0.47d, 0.40p, 2.65std) 1.01x invariant, -0.06ms (-0.59d, 0.30p, 0.10std) 1.00x invariant, 0.71μs (0.05d, 0.92p, 13.15std)
WGLMakie 4.38s (4.36, 4.41) 0.02+- 103.59ms (103.04, 104.54) 0.59+- 8.83s (8.78, 8.91) 0.05+- 9.69ms (9.60, 9.76) 0.06+- 69.92ms (69.32, 71.45) 0.73+-
master 4.39s (4.36, 4.40) 0.02+- 104.48ms (103.16, 106.18) 0.93+- 8.83s (8.79, 8.89) 0.03+- 9.85ms (9.62, 10.78) 0.42+- 71.14ms (68.81, 82.37) 4.97+-
evaluation 1.00x invariant, -0.0s (-0.13d, 0.81p, 0.02std) 1.01x invariant, -0.89ms (-1.15d, 0.06p, 0.76std) 1.00x invariant, 0.0s (0.03d, 0.96p, 0.04std) 1.02x invariant, -0.16ms (-0.52d, 0.36p, 0.24std) 1.02x invariant, -1.22ms (-0.34d, 0.54p, 2.85std)

@ffreyer ffreyer changed the base branch from master to ff/bbox_fixes May 13, 2024 20:07
Comment on lines +1154 to +1157
ax, plot_top = heatmap(fig[1, 1], randn(10, 10), colormap = [:transparent])
# Plot some recipes at the level below the contour
scatterlineplot_1 = scatterlines!(plot_top, 1:10, 1:10; linewidth = 20, markersize = 20, color = :red)
scatterlineplot_2 = scatterlines!(plot_top, 1:10, 1:10; linewidth = 20, markersize = 30, color = :blue)
scatterlineplot_1 = scatterlines!(ax, 1:10, 1:10; linewidth = 20, markersize = 20, color = :red)
scatterlineplot_2 = scatterlines!(ax, 1:10, 1:10; linewidth = 20, markersize = 30, color = :blue)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test failed because of what I'd say is undefined behavior - plotting to a primitive plot.
Specifically because data_limits has a specific overload for Heatmap, thus using heatmap limits, while boundingbox attempts to recognize primitives by their lack of child plots. Since heatmap has children here, boundingbox uses scatter + lines for limits.
Plotting to a primitive also results in other weirdness - the heatmap doesn't show and the axis uses tight limits.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, plotting to a primitive outside a recipe?! That's something we shouldn't do in any case ;) Didn't realize we actually do this in the tests!

@ffreyer ffreyer marked this pull request as ready for review May 13, 2024 20:47
@ffreyer
Copy link
Collaborator Author

ffreyer commented May 13, 2024

Added refimg is only meant to test whether the Axis correctly bring splots in view that have scale + translation + transform_func:
image

Also tests didn't run here because the pr is based on #3856. Locally Makie, CairoMakie, GLMakie passed (exept for the random failure from #3856)

@ffreyer
Copy link
Collaborator Author

ffreyer commented May 14, 2024

We should merge #3856 first, rebase and let tests run here before merging

Base automatically changed from ff/bbox_fixes to master May 14, 2024 18:17
@SimonDanisch SimonDanisch reopened this May 16, 2024
@SimonDanisch SimonDanisch merged commit 179d8fc into master May 16, 2024
34 checks passed
@SimonDanisch SimonDanisch deleted the ff/axis_limits branch May 16, 2024 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fit objects into scene after Makie transformations
3 participants