Countour/Contourf

Plots.Controur() allows x,y,z to be Vector{Float64}.
AbstractPlotting.Contour() chokes when I swap out the Plots version for the Makie version.

ERROR: There was no `AbstractPlotting.convert_arguments` overload found for
the plot type Combined{AbstractPlotting.contour,Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1}}}, or its conversion trait AbstractPlotting.SurfaceLike().
The arguments were:
(Array{Float64,1}, Array{Float64,1}, Array{Float64,1})

To fix this, define `AbstractPlotting.convert_arguments(::Combined{AbstractPlotting.contour,Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1}}}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,1})`.

This would just be a matter of adding a convert method for this case. What isn’t clear to me is what format these vectors are in, and therefore what kind of conversion logic to 2D we would need. Is there a standard for this kind of thing?

1 Like

Plots.contour does it, so what do they do?

I don’t know, would be interesting if you could find out

I should have said the Plots backend I was using was plotly. I don’t know if that matters. I started to dig around on github, but that has not been fruitful. I’ll see if I can run it through the debugger and figure out how it converts it to a surface.

At least contourf and contour algorithms in their current state need data on a rectilinear grid, so there must be a fool-proof way to convert vectors into that. I’m just wondering what happens if data is missing, duplicated, non-rectilinear, all those edge cases

The debugger did not help me much.

I think, if I just made my z-vector 2D, it should work. There is really no reason I can’t do that.

https://juliageometry.github.io/Contour.jl/stable/tutorial.html

The contour interface is a bit finicky.

Struggling to figure out adding a title to it and axis labels. I need to find that example.

You mean in Makie or in Plots now?

In Makie, what is the syntax to add a title to the contour plot if I’m doing a layout?

    f=Figure()

    _,co1=contourf(f[1,1][1,1],x,z1,
                contour_labels=true,levels=20,colormap=:lightrainbow, title="Z1")
    Colorbar(f[1,1][1,2],co1,width=20)
    #f[1,1]=Axis(f,title="Mach")

    _,co1=contourf(f[1,2][1,1],x,y,z2,
                contour_labels=true,levels=20,colormap=:lightrainbow)
    Colorbar(f[1,2][1,2],co1,width=20)

This is what I had to do.

f=Figure()

    _,co1=contourf(f[1,1][2,1],x,y,z1,
                contour_labels=true,levels=20,colormap=:lightrainbow)
    Colorbar(f[1,1][2,2],co1,width=20)
    Label(f[1,1][1,1:2],text="Z1")
    

now I need to figure out xlabel! and ylabel!.

Surely there is an easier way… no?

http://makie.juliaplots.org/stable/plot_method_signatures.html#Special-Keyword-Arguments

Excellent! The “end comma” on the kw-argument! That is what was disallowing it.

should have been

contour(blah,blah,blah, axis = (title="blah", xlabel="xblah", ylabel="yblah", ))

Anyone know where the contour line labels are hiding for Makie? contour_labels=true does not seem to work like it does in plots and I don’t see it in the attributes list.

you only need the end comma if you only have one argument, because (a = 3) is not parsed as a namedtuple

1 Like

and we don’t have contour labels implemented currently