Skip to content

Handle dim_conversions in Axis3 #4964

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fhagemann
Copy link

Description

Fixes #4963.

This is my attempt on fixing the issue #4963 I created, namely handling DimConversions in Axis3. It solves the problem I reported in the issue, but I cannot judge whether this is a full solution, so maybe some expert should review and judge the completeness of this.

I looked into how dim_conversion is handled in Axis, and it looks like, in Axis3,

  1. the dimensions passed to the axis were just not passed to the newly created Scene when initializing the block
  2. the conversions were not passed to get_ticks when creating the ticknodes.

This should be fixed now in this PR.

Example 1:

using CairoMakie, Unitful
fig = Makie.Figure()
ax = Makie.Axis3(fig[1,1], dim1_conversion = Makie.UnitfulConversion(u"m", units_in_label = true))
@show ax.scene.conversions[1]
fig

Before this PR:
ax.scene.conversions would ignore what was passed and the axis ticklabels would not show the unit.

ax.scene.conversions[1] = nothing

image

Using this PR:
The ax.scene.conversions has the dim_conversion passed to it and the axis ticklabels show units now.

ax.scene.conversions[1] = Makie.UnitfulConversion(Observable{Any}(m), false, Observable(true), Dict{String, Tuple{Any, Any}}())

image

Example 2:

using CairoMakie, Unitful
fig = Makie.Figure()
ax = Makie.Axis3(fig[1,1], dim1_conversion = Makie.UnitfulConversion(u"m", units_in_label = true))
Makie.scatter!(ax, rand(10)*u"m", rand(10), rand(10))
@show ax.scene.conversions[1]
fig

Before this PR:
ax.scene.conversions would "guess" the unit conversion (automatic), in this case dm (decimeter) but not display them --> BUG

ax.scene.conversions[1] = Makie.UnitfulConversion(Observable{Any}(dm), true, Observable(true), Dict{String, Tuple{Any, Any}}("656252" => (0.0911379250149652 m, 0.8551460469135354 m)))

image

Using this PR:
ax.scene.conversions would still use the dim_conversion defined when creating the Axis3

ax.scene.conversions[1] = Makie.UnitfulConversion(Observable{Any}(m), false, Observable(true), Dict{String, Tuple{Any, Any}}())

image

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.

@github-project-automation github-project-automation bot moved this to Work in progress in PR review May 9, 2025
@fhagemann
Copy link
Author

I am very new to writing units tests or reference image tests, so I would need some guidance or help there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Work in progress
Development

Successfully merging this pull request may close these issues.

Handling of units in Axis3
1 participant