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

Add show_data for band #2497

Merged
merged 6 commits into from
Jan 1, 2023
Merged

Add show_data for band #2497

merged 6 commits into from
Jan 1, 2023

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Dec 13, 2022

Description

Adds a custom show_data for band which displays the x position of the mouse and the relevant (interpolated) min and max value of the band at that x value. This also affects density and whatever else relies on band. Currently this shows a bounding box for the underlying mesh.

I'm making the assumptions that

  • band is used in 2D
  • x values are sorted in plot.converted
  • plots.converted is always 2 Point2f arrays, with the first being low values and the second being high values
  • x values between low and high points match

Example with density(rand(100)): (3rd commit)

Screenshot from 2022-12-14 11-41-57

Type of change

  • New feature (non-breaking change which adds functionality)

Well technically it's changing the current behavior but a bounding box is not a useful thing to get here...

Checklist

  • Added an entry in NEWS.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 Dec 13, 2022

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(display(fig))
using create display create display
GLMakie 29.06s (28.97, 29.14) 0.07+- 17.62s (17.43, 17.75) 0.11+- 16.63s (16.46, 16.81) 0.11+- 10.27ms (10.16, 10.33) 0.06+- 114.17ms (112.64, 115.88) 1.24+-
master 29.30s (29.16, 29.44) 0.10+- 17.61s (17.38, 17.85) 0.17+- 16.57s (16.42, 16.75) 0.13+- 10.47ms (10.31, 10.90) 0.20+- 115.20ms (114.09, 116.29) 0.76+-
evaluation -0.82%, -0.24s faster ✓ (-2.73d, 0.00p, 0.09std) +0.08%, 0.01s invariant (0.10d, 0.85p, 0.14std) +0.35%, 0.06s invariant (0.48d, 0.39p, 0.12std) -1.98%, -0.2ms faster ✓ (-1.40d, 0.03p, 0.13std) -0.90%, -1.03ms invariant (-1.01d, 0.09p, 1.00std)
CairoMakie 26.90s (26.77, 26.96) 0.06+- 15.96s (15.83, 16.06) 0.10+- 2.42s (2.41, 2.46) 0.02+- 11.26ms (11.19, 11.37) 0.06+- 4.47ms (4.45, 4.51) 0.02+-
master 26.99s (26.80, 27.22) 0.14+- 16.27s (16.06, 16.67) 0.20+- 2.44s (2.40, 2.48) 0.02+- 11.16ms (10.99, 11.31) 0.11+- 4.44ms (4.35, 4.49) 0.05+-
evaluation -0.31%, -0.08s invariant (-0.77d, 0.18p, 0.10std) -2.00%, -0.32s faster ✓ (-2.03d, 0.00p, 0.15std) -0.42%, -0.01s invariant (-0.48d, 0.39p, 0.02std) +0.94%, 0.11ms invariant (1.15d, 0.06p, 0.09std) +0.74%, 0.03ms invariant (0.92d, 0.12p, 0.03std)
WGLMakie 31.56s (31.32, 31.91) 0.19+- 25.62s (25.25, 26.02) 0.25+- 41.46s (40.94, 42.28) 0.52+- 15.28ms (12.78, 28.58) 5.87+- 1.83s (1.79, 1.87) 0.03+-
master 31.55s (31.42, 31.69) 0.10+- 25.60s (25.48, 25.73) 0.09+- 42.60s (40.54, 54.17) 5.10+- 12.37ms (11.71, 13.89) 0.70+- 1.63s (1.60, 1.66) 0.03+-
evaluation +0.02%, 0.01s invariant (0.04d, 0.94p, 0.15std) +0.10%, 0.02s invariant (0.13d, 0.81p, 0.17std) -2.75%, -1.14s invariant (-0.31d, 0.58p, 2.81std) +19.08%, 2.92ms noisy🤷‍♀️ (0.70d, 0.24p, 3.29std) +10.91%, 0.2s slower❌ (6.56d, 0.00p, 0.03std)

@ffreyer ffreyer marked this pull request as ready for review December 14, 2022 10:47
@jkrumbiegel
Copy link
Member

jkrumbiegel commented Dec 17, 2022

Looks good, the only thing is that I think (0.345, 0.000..0.932) like in the example is a bit hard to read. Maybe spaces around the .. like (0.345, 0.000 .. 0.932)? Or any other suggestions?

Oh and what happens with vertical bands or flipped densities?

@ffreyer
Copy link
Collaborator Author

ffreyer commented Dec 17, 2022

Do we have (x, x, y) bands? I don't see a keyword or plot method for it.

@ffreyer
Copy link
Collaborator Author

ffreyer commented Dec 17, 2022

Oh it's a raw input of Points. I'll have to tweak this then.

Looks good, the only thing is that I think (0.345, 0.000..0.932) like in the example is a bit hard to read. Maybe spaces around the .. like (0.345, 0.000 .. 0.932)? Or any other suggestions?

Some thoughts:

  • ($x, $ymin, $ymax) (or $xmin, $xmax, $y) was my first thought, but that's even worse for readability imo
  • Two lines like "($x, $ymin)\n($x, $ymax)" would be another option
  • The $ymin..$ymax matches the Interval notation which I thought was rather fitting for band. I guess we could also have ($ymin, $ymax) or "$ymin <= y <= $ymax"
  • Displaying the current position rather than band min/max would be an option, but I think less useful? I think that's more something for a separate function/tool which just shows mouseposition() regardless.
  • Having two or even three (top, bottom, current pos) tooltips would require reworking tooltip! and is too much noise I think.

@ffreyer
Copy link
Collaborator Author

ffreyer commented Dec 25, 2022

I got stuck for a while trying to figure out a direct way to find the line I need to draw and ultimately just used an iterative method. Now it can handle densities in :x and :y direction and also bands like this:

inner = [(1 + rand()) * Point2f(cos(phi), sin(phi)) for phi in range(0, 2pi, length=51)]
outer = [(4 + rand()) * Point2f(cos(phi), sin(phi)) for phi in range(0, 2pi, length=51)]
fig, ax, p = band(inner, outer)
di = DataInspector(fig)
fig

Screenshot from 2022-12-25 03-30-40

You can also swap outer and inner without issues. (It will break if the quads look like |><|, e.g. if you swap lows and highs throughout the band. At this point band is malformed anyway though)

@SimonDanisch SimonDanisch merged commit 9e65db5 into master Jan 1, 2023
@SimonDanisch SimonDanisch deleted the ff/band_inspector branch January 1, 2023 18: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.

4 participants