Second order polynomial fit in Makie.jl?

Is there a way to get the Polynomial. jl operation fit() to work in Makie.jl? I’ve tried to use the Makie.convert_argument() and other iterations of it, but, maybe I’m using it incorrectly?

Here is where I left it at my last attempt:

agmt_dlm = readdlm("/home/rob/Documents/julia/dy_comb_tenv3/AGMT_with_decyr.tenv3")
agmt_decyr = convert(Vector{Float64}, agmt_dlm[:, 3])
agmt_Vres = convert(Vector{Float64}, agmt_dlm[:, 12])

# agmt_fit = Makie.convert_single_argument(, agmt_Vres, 2))

dark_latex = merge(theme_dark(), theme_latexfonts())

with_theme(dark_latex, fontsize = 20) do 
    fig = Figure(size = (1200, 800))
    ax1 = Axis(fig[1,1],
    ylabel = "Vert Displacement",
    title = "AGMT" )

    CairoMakie.scatter!(convert(Vector{Float64},agmt_dlm[:, 3]), 
    convert(Vector{Float64},agmt_dlm[:, 6]), 
    markersize = 7,
    color = convert(Vector{Float64}, agmt_dlm[:, 6]), colormap = :lightrainbow, 
    strokewidth = 0.3, strokecolor = :white)

    CairoMakie.lines!(convert(Vector{Float64}, agmt_dlm[:, 3]), 
    convert(Vector{Float64}, agmt_dlm[:, 10]), 
    color = :white, linewidth = 3)

    ax2 = Axis(fig[2, 1],
    ylabel = "Residual Displacement")

    CairoMakie.scatter!(ax2, convert(Vector{Float64}, agmt_dlm[:, 3]),
    convert(Vector{Float64}, agmt_dlm[:, 12]),
    markersize = 7,
    color = convert(Vector{Float64}, agmt_dlm[:, 12]), colormap = :lightrainbow,
    strokewidth = 0.3, strokecolor = :white)

    Makie.convert_arguments(CairoMakie.lines!(ax2,, agmt_Vres, 2),
    color = :white, linewidth = 3))

    #save("agmt_earthday.png", fig)

Here’s the error:

ERROR: `Makie.convert_arguments` for the plot type Lines and its conversion trait PointBased() was unsuccessful.

The signature that could not be converted was:
::Polynomial{Float64, :x}

Makie needs to convert all plot input arguments to types that can be consumed by the backends (typically Arrays with Float32 elements).
You can define a method for `Makie.convert_arguments` (a type recipe) for these types or their supertypes to make this set of arguments convertible (See

Alternatively, you can define `Makie.convert_single_argument` for single arguments which have types that are unknown to Makie but which can be converted to known types and fed back to the conversion pipeline.

Which, I tried to follow, but to no avail.

I just want a white, fitted line, on my lower plot :sob: it’s naked without it.

The easy way is to evaluate your fit and plot that:

    poly =, agmt_Vres, 2)
    evaluation_points = range(extrema(agmt_decyr)..., length=100)
    fit_values = poly.(evalutaion_points)
    CairoMakie.lines!(ax2, evaulation_points, fit_values; color = :white, linewidth = 3)

The hard way is to write a Makie type recipe for the Polynomial type:
and make a PR to the Polynomials package.

1 Like

Thank youuuu! This worked perfectly.