How to Handle MissingException in Makie?

Hi all,

I have columns in my dataframe as follows:

image

These columns contain Ints as well as missings.
I know that Makie.jl handles missings per this issue: handling vectors with `Missing` in type signature (even if there are no missing values) · Issue #532 · JuliaPlots/Makie.jl · GitHub

When I try to use this data directly (i.e. mydataframe.numerator) from the dataframe within a Makie plotting function, I get this error:

ERROR: MissingException: cannot convert a missing value to type Int64: use Union{Int64, Missing} instead

What my question is, is when using this data, what do I have to do exactly to remedy this error that Makie throws?

Thanks!

~ tcp :deciduous_tree:

What is the exact call that you see this with?

It was when I had a call like this:

            barplot!(
                df.numerator,
                color = :tomato,
                strokecolor = :black,
                strokewidth = 1,
                direction = :x,
            )

However, looking at the issue again and rereading the MissingException, I realized it was a pretty simple fix:

convert(Vector{Union{Missing, Float64}}, df.numerator)

Now I am no longer getting that error! :smile:

Weird, this works for me:

barplot(
    [1, 2, 3, 4, missing, 5],
    color = :tomato,
    strokecolor = :black,
    strokewidth = 1,
    direction = :x,
)

This is peculiar.
Let me double check.

You were right, that wasn’t what I thought the error was coming from - it was actually coming from a calculation I was doing in my label formatting.
It does just work - I just had an error elsewhere.
Thanks!