# Countour/Contourf

**URL:** <https://discourse.julialang.org/t/countour-contourf/55933>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [February 24, 2021, 2:08pm UTC](https://discourse.julialang.org/t/countour-contourf/55933 "2021-02-24T14:08:03Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [February 24, 2021, 2:08pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/1 "2021-02-24T14:08:03Z")

</div>

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

```julia
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})`.

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [February 24, 2021, 2:12pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/2 "2021-02-24T14:12:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [February 24, 2021, 3:41pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/3 "2021-02-24T15:41:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [February 24, 2021, 3:49pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/4 "2021-02-24T15:49:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [February 24, 2021, 4:25pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/5 "2021-02-24T16:25:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [February 24, 2021, 4:27pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/6 "2021-02-24T16:27:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [February 24, 2021, 4:49pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/7 "2021-02-24T16:49:06Z")

</div>

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](https://juliageometry.github.io/Contour.jl/stable/tutorial.html)

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [February 24, 2021, 6:45pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/8 "2021-02-24T18:45:54Z")

</div>

The contour interface is a bit finicky.

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [February 24, 2021, 6:48pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/9 "2021-02-24T18:48:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [February 24, 2021, 7:13pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/10 "2021-02-24T19:13:23Z")

</div>

You mean in Makie or in Plots now?

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [February 24, 2021, 11:59pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/11 "2021-02-24T23:59:53Z")

</div>

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

```julia
    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)

```

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [February 25, 2021, 2:02am UTC](https://discourse.julialang.org/t/countour-contourf/55933/12 "2021-02-25T02:02:21Z")

</div>

This is what I had to do.

```julia
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?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [February 25, 2021, 5:52am UTC](https://discourse.julialang.org/t/countour-contourf/55933/13 "2021-02-25T05:52:48Z")

</div>

[http://makie.juliaplots.org/stable/plot\_method\_signatures.html#Special-Keyword-Arguments](http://makie.juliaplots.org/stable/plot_method_signatures.html#Special-Keyword-Arguments)

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [February 25, 2021, 12:34pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/14 "2021-02-25T12:34:46Z")

</div>

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

should have been

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

```

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [February 25, 2021, 12:36pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/15 "2021-02-25T12:36:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [February 25, 2021, 12:36pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/16 "2021-02-25T12:36:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [February 25, 2021, 12:36pm UTC](https://discourse.julialang.org/t/countour-contourf/55933/17 "2021-02-25T12:36:37Z")

</div>

and we don’t have contour labels implemented currently
