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

Colorbar for contour plot with uneven spacing of contour lines #3871

Closed
rkube opened this issue May 16, 2024 · 1 comment
Closed

Colorbar for contour plot with uneven spacing of contour lines #3871

rkube opened this issue May 16, 2024 · 1 comment
Labels
bug colors color, colormap, colorrange, alpha, etc Legend & Colorbar Makie Backend independent issues (Makie core) (tri)contour(f) not 3D contour, that's volume

Comments

@rkube
Copy link

rkube commented May 16, 2024

Hi,
I’m trying to add a colorbar for a contour plot with uneven spacing between the contour lines. The contour plot

using CairoMakie

fig = let 
    fig = Figure()
    ax = Axis(fig[1, 1])

    xrg = 0.0:0.01:1.0
    yrg = -1.0:0.1:1.0

    z(x, y) = x.^2 .+ y.^2

    zvals = zeros(length(xrg), length(yrg))
    for (ix_x, x) ∈ enumerate(xrg)
        for (ix_y, y) ∈ enumerate(yrg)
            zvals[ix_x, ix_y] = z(x,y)
        end
    end

    cf = contour!(ax, xrg, yrg, zvals, levels=cat(0.1:0.05:0.3, 0.4:0.1:1.0, dims=1), labels=true, colormap=:hsv)
    #Colorbar(fig[1, 2], cf)
    fig
end

When I naively try to add a colorbar I get the error

ERROR: Multiple colormaps found for plot MakieCore.Text{Tuple{Vector{Point{2, Float32}}}}, please specify which one to use manually. Please overload `Makie.extract_colormap(::MakieCore.Text{Tuple{Vector{Point{2, Float32}}}})` to allow for the automatical creation of a Colorbar.

I also tried wrapping into a categorical colormap and get the same error.

Makie version: [13f3f980] CairoMakie v0.12.0
Platform: x84_64 (linux)

@rkube rkube added the bug label May 16, 2024
@asinghvi17 asinghvi17 added the Makie Backend independent issues (Makie core) label May 17, 2024
@ffreyer ffreyer added plot Related to plot object Legend & Colorbar colors color, colormap, colorrange, alpha, etc (tri)contour(f) not 3D contour, that's volume and removed plot Related to plot object labels Aug 28, 2024
@ffreyer
Copy link
Collaborator

ffreyer commented Aug 28, 2024

Closing this as a special case of #4036

@ffreyer ffreyer closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug colors color, colormap, colorrange, alpha, etc Legend & Colorbar 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