0
votes

I'm trying to make a two-paneled figure in Julia, where the left panel is a heatmap and the right panel is a histogram.

Here is my code for doing so, with array X and vector y

begin
    f = Figure()
    CairoMakie.heatmap(f[1,1], X)
    CairoMakie.hist(f[1,2], y)
    f
end

I would like to force the left panel (the heatmap) to have aspect ratio 1.

All the tutorials (eg this one) recommend setting up an axis, which I think would be something along the following code:

begin
    f = Figure()
    ax1 = Axis(f[1,1], aspect = 1)
    ax2 = Axis(f[1,2])
    CairoMakie.heatmap(ax1, X)
    CairoMakie.hist(ax2, y)
    f
end

However, when I do so, I get the following error:

`Makie.convert_arguments` for the plot type MakieCore.Heatmap{Tuple{Makie.MakieLayout.Axis, Matrix{Float64}}} and its conversion trait MakieCore.DiscreteSurface() was unsuccessful.

The signature that could not be converted was:

::Makie.MakieLayout.Axis, ::Matrix{Float32}

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 http://makie.juliaplots.org/stable/documentation/recipes/index.html).

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.

error(::String)@error.jl:33
var"#convert_arguments#144"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(MakieCore.convert_arguments), ::Type{MakieCore.Heatmap{Tuple{Makie.MakieLayout.Axis, Matrix{Float64}}}}, ::Makie.MakieLayout.Axis, ::Vararg{Any})@conversions.jl:17
convert_arguments(::Type{MakieCore.Heatmap{Tuple{Makie.MakieLayout.Axis, Matrix{Float64}}}}, ::Makie.MakieLayout.Axis, ::Matrix{Float32})@conversions.jl:8
convert_arguments_individually(::Type{MakieCore.Heatmap{Tuple{Makie.MakieLayout.Axis, Matrix{Float64}}}}, ::Makie.MakieLayout.Axis, ::Vararg{Any})@conversions.jl:51
var"#convert_arguments#144"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(MakieCore.convert_arguments), ::Type{MakieCore.Heatmap{Tuple{Makie.MakieLayout.Axis, Matrix{Float64}}}}, ::Makie.MakieLayout.Axis, ::Vararg{Any})@conversions.jl:14
convert_arguments(::Type{MakieCore.Heatmap{Tuple{Makie.MakieLayout.Axis, Matrix{Float64}}}}, ::Makie.MakieLayout.Axis, ::Matrix{Float64})@conversions.jl:8
var"#plot!#139"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(MakieCore.plot!), ::Makie.Scene, ::Type{MakieCore.Heatmap}, ::MakieCore.Attributes, ::Makie.MakieLayout.Axis, ::Vararg{Any})@interfaces.jl:302
plot!(::Makie.Scene, ::Type{MakieCore.Heatmap}, ::MakieCore.Attributes, ::Makie.MakieLayout.Axis, ::Matrix{Float64})@interfaces.jl:288
var"#plot#929"(::NamedTuple{(), Tuple{}}, ::NamedTuple{(), Tuple{}}, ::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:colorrange, :colormap), Tuple{Tuple{Int64, Int64}, Symbol}}}, ::typeof(MakieCore.plot), ::Type{MakieCore.Heatmap}, ::Makie.MakieLayout.Axis, ::Vararg{Any})@figureplotting.jl:28
var"#heatmap#19"(::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:colorrange, :colormap), Tuple{Tuple{Int64, Int64}, Symbol}}}, ::typeof(MakieCore.heatmap), ::Makie.MakieLayout.Axis, ::Vararg{Any})@recipes.jl:33
top-level scope@Local: 6

I really don't understand what is going on with this error, even after googling it.

I am curious if anyone has any insights into what this error is, or what I can do to make my heatmap have aspect ratio 1?