Skip to content

Conversation

@ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Jul 23, 2025

Description

Mildly related to #5194

This pr updates contour(..., ::Array{Float, 3}) to rely on the compute graph and introduced some changes to the colormapping:

  • [change] colorrange now defaults to the extrema of levels rather than the extrema of the given data
  • [fix] colormap used to always generate colors for the full value range minimum(volumedata) .. maximum(volumedata), but report colorrange as its limits to volume. This made any 3D contour with a non default colorrange incorrect. Now the colormap generates for slightly padded colorrange (to include a transparent min and max color) which gets passed down correctly.
  • [fix] isorange is now a setable attribute again
  • [change] default isorange no longer assumes uniform levels. Instead it's generated based on the minimum distance between levels
  • [internal change] The number of colors in the colormap is no longer based on the number of levels. Instead it aims to resolve the padded colorrange in steps of isorange, so that each iso surface has at least one non-transparent color mapped to it
  • [change] Colorbar now looks at colormap alpha as a binary so that transparent contours still have a readable Colorbar

By example:

r = range(-1.2, 1.2, 21)
data = Array{Float32, 3}(undef, 21, 21, 21)
for (i, x) in enumerate(r)
    for (j, y) in enumerate(r)
        for (k, z) in enumerate(r)
            data[i, j, k] = norm(Vec3f(x,y,z))
        end
    end
end
f = Figure(size = (400, 1200))
contour(f[1, 1], data, alpha = 0.1)
contour(f[2, 1], data, alpha = 0.1, levels = 0:0.2:1)
contour(f[3, 1], data, alpha = 0.1, colorrange = (0, 1))
contour(f[4, 1], data, alpha = 0.1, levels = 0:0.2:1, colorrange = (0, 1))
f
before after
Screenshot 2025-07-28 160442 Screenshot 2025-07-28 180651
  • 1, 2 show off different colorrange defaults
  • 3, 4 show off the colormap - colorrange missmatch

TODO:

  • cleanup Colorbar for 3D contour
  • reconsider default colorrange (should it continue to look at the full value range instead?)
  • reconsider color sample density (is 1-2 colors per sample enough?)

Type of change

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

... maybe breaking due to change in colorrange defaulting?

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 Jul 23, 2025
@MakieBot
Copy link
Collaborator

MakieBot commented Jul 23, 2025

Benchmark Results

SHA: 2db05a7fc471ccffddac2f9dbae0bb4143f66619

Warning

These results are subject to substantial noise because GitHub's CI runs on shared machines that are not ideally suited for benchmarking.

GLMakie
CairoMakie
WGLMakie

@ffreyer ffreyer marked this pull request as ready for review August 5, 2025 14:11
@ffreyer ffreyer moved this from Work in progress to Ready to review in PR review Aug 5, 2025
@SimonDanisch
Copy link
Member

Is this ready?

@ffreyer ffreyer merged commit 1da0f1e into master Aug 16, 2025
@ffreyer ffreyer deleted the ff/3d-contour branch August 16, 2025 21:25
@github-project-automation github-project-automation bot moved this from Ready to review to Merged in PR review Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

4 participants