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

support images with reversed axes #3989

Closed
wants to merge 8 commits into from
Closed

Conversation

aplavin
Copy link
Contributor

@aplavin aplavin commented Jun 26, 2024

Description

The whole pipeline almost-supported them already, here I just make a few minor fixes where the assumption of increasing values was baked in.

Type of change

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

Checklist

  • Added unit tests for new algorithms, conversion methods, etc.

@aplavin
Copy link
Contributor Author

aplavin commented Jul 3, 2024

should it go to the changelog? not a new feature, just fixing existing behavior, making it more uniform and consistent

@SimonDanisch
Copy link
Member

Yeah definitely changelog worthy I'd say

@aplavin
Copy link
Contributor Author

aplavin commented Jul 4, 2024

added!
anything else remains to do?

@aplavin
Copy link
Contributor Author

aplavin commented Jul 16, 2024

bump...

@ffreyer
Copy link
Collaborator

ffreyer commented Jul 19, 2024

Added this refimg:
Screenshot 2024-07-19 151852

This works for me across GLMakie, CairoMakie and WGLMakie for heatmap with ranges. It doesn't with image in general, Intervals (e.g. 4..1 errors) and Vectors (e.g. [4,3,2,1] doesn't do anything). I think those would all be TODOs before merging, and the refimg test should then also include them. (And we should have one for image too)

@aplavin
Copy link
Contributor Author

aplavin commented Jul 19, 2024

It doesn't with image in general, Intervals (e.g. 4..1 errors) and Vectors (e.g. [4,3,2,1] doesn't do anything)

What exactly doesn't work?

julia> using CairoMakie
julia> fig = Figure()
julia> X = rand(10, 10)
julia> image(fig[1,1], 0..1, 1:10, X)
julia> image(fig[1,2], 1..0, 1:10, X)
julia> fig

gives (with this PR):
image
L/R images are clearly flipped, as expected.

@ffreyer
Copy link
Collaborator

ffreyer commented Jul 26, 2024

Oh I missed your response somehow. I got things a bit mixed up in my comment. Testing again I get:

Heatmap:

  • reversed Intervals error
  • reverse ranges work
  • reversed vector works

Image:

  • reverse Interval works
  • reverse range doesn't work
  • reversed vector doesn't work

Thinking about it again it's probably not necessary to get ranges and vectors to work for Image since they are deprecated. Interval in heatmap should be fixed though. And the refimg should test everything that works, i.e. reversed Interval, Range and Vector for heatmap and reversed Interval for image.

Edit: Next two commits resolve this

Comment on lines +652 to +653
to_linspace(interval::Interval, N) = range(leftendpoint(interval), stop = rightendpoint(interval), length = N)
to_linspace(x, N) = range(first(x), stop = last(x), length = N)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@SimonDanisch @jkrumbiegel Is it fine to switch away from minimum and maximum to enable reverse image/heatmap axes? Should we consider this breaking?

(This is fixing the points I made in the last comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this change is fine we can merge this

Copy link
Member

Choose a reason for hiding this comment

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

Is that in the code path, that already warns for vectors?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I guess it is... So we don't allow vectors for images anymore anyways 🤷
It's not yet erroring, but should already warn to not use it.
So shouldn't be breaking

Copy link
Collaborator

@ffreyer ffreyer Jul 29, 2024

Choose a reason for hiding this comment

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

We have two functions with that change here:

  • to_interval affecting Image, Volume (errors in data_limits with reversed axis though)
  • to_linspace affecting PointBased w/ (Interval, Interval, Matrix), heatmap

What changed as far as I can tell:

  • heatmap no longer errors for reverse intervals but otherwise works the same (is the RangeLike convert not getting hit?)
  • image no longer errors on reverse intervals and allows for reversing, which it previously didn't. This is visually different
  • PointBased no longer errors with (Interval, Interval, Matrix), but still with something like (Interval, Vector)
  • volume errors in data_limits instead of convert_arguments with reversed limits

@aplavin
Copy link
Contributor Author

aplavin commented Aug 12, 2024

Bump :)

@ffreyer ffreyer mentioned this pull request Aug 13, 2024
@aplavin
Copy link
Contributor Author

aplavin commented Aug 24, 2024

Any issues with this?.. Or suggestions on how to proceed with this bugfix?

@aplavin
Copy link
Contributor Author

aplavin commented Sep 9, 2024

another bump...

@SimonDanisch
Copy link
Member

Sorry I guess we're all a bit unsure how to best do this, and if this PR is enough and whether we have enough tests.
I think this also changed recently with my heatmap fastpath PR - in the backends it should now always be Makie.EndPoints for x,y that have just a beginning and end.
Lets try to resolve the conflict and merge this soon one way or another.

@aplavin
Copy link
Contributor Author

aplavin commented Sep 9, 2024

Hmm, the new behavior for reversed axes seems worse: earlier, it threw an error, but now displays the exact same plot as non-reversed:
image
This leads to a mismatch between coordinates and actual values, and can potentially be highly misleading.

Trying to understand EndPoints and its handling... I wonder what was the issue with simply using an interval instead?

# But ClosedInterval doesn't support all operations/constructions we need

Best to make a new PR on top of the current master I guess.

@aplavin aplavin closed this Sep 9, 2024
@aplavin aplavin mentioned this pull request Sep 9, 2024
2 tasks
@SimonDanisch
Copy link
Member

Maybe I started using minmax, which is incorrect here, isn't it?

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

Successfully merging this pull request may close these issues.

3 participants