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

Contour labels obscured for data with NaNs #4418

Open
3 tasks done
haakon-e opened this issue Sep 27, 2024 · 0 comments
Open
3 tasks done

Contour labels obscured for data with NaNs #4418

haakon-e opened this issue Sep 27, 2024 · 0 comments
Labels
bug Makie Backend independent issues (Makie core) (tri)contour(f) not 3D contour, that's volume

Comments

@haakon-e
Copy link
Contributor

Certain fields that contain NaNs result in rendering errors for contours with labels=true

Code setup
using CairoMakie
function f_ex(x,y, set_nans=true)
    # Define coefficients
    a = 1000  # Overall scale
    b = 4     # Controls the "peak" location
    c = 0.3   # Controls the rate of decrease for large x and y
    
    # Create a surface that rises and then falls
    z = a * (1 - (x - 0.5)^2 - (y - 0.3)^2 - c * (x * y))
    
    # Adjust to ensure positive values and add base level
    z = max(z, 0) + 200

	set_nans && y > 2x + 0.4 && return NaN
    
    return z
end
function make_contour_plot(; set_nans, levels = 900:50:1100)
    x,y = 0:0.01:0.5, 0:0.01:0.8
    z = f_ex.(x,y',true)
    f,a,c = contourf(x,y,z)
    contour!(a,x,y,z; labels=true, color=:black, levels)
    f
end

Case 1: The field has no NaNs

In this case, labels show as expected

make_contour_plot(set_nans=false)

image

Case 2: Set some values to NaN

In this case, the contour strikes through some of the labels

make_contour_plot(set_nans=true)

image

Case 3: Show fewer contours

If none of the contours intersect the NaNs, labels show as expected:

make_contour_plot(set_nans=true, levels = 1000:50:1100)

image


  • what version of Makie are you running? (]st -m Makie) Makie v0.21.11
  • can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)
  • What platform + GPU are you on? Mac M1
@haakon-e haakon-e added the bug label Sep 27, 2024
@asinghvi17 asinghvi17 added the (tri)contour(f) not 3D contour, that's volume label Sep 27, 2024
@ffreyer ffreyer added the Makie Backend independent issues (Makie core) label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Makie Backend independent issues (Makie core) (tri)contour(f) not 3D contour, that's volume
Projects
None yet
Development

No branches or pull requests

3 participants