# How to Handle MissingException in Makie?

**URL:** <https://discourse.julialang.org/t/how-to-handle-missingexception-in-makie/82325>\
**Category:** Visualization\
**Tags:** error, makie, missing-values\
**Created:** [June 6, 2022, 4:43pm UTC](https://discourse.julialang.org/t/how-to-handle-missingexception-in-makie/82325 "2022-06-06T16:43:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [June 6, 2022, 4:43pm UTC](https://discourse.julialang.org/t/how-to-handle-missingexception-in-makie/82325/1 "2022-06-06T16:43:09Z")

</div>

Hi all,

I have columns in my dataframe as follows:

![image](https://global.discourse-cdn.com/julialang/original/3X/c/8/c895eee47b115db60bdad4bc389b88c8a100bbc3.png)

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](https://github.com/JuliaPlots/Makie.jl/issues/532)

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

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

---

<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:** [June 6, 2022, 5:15pm UTC](https://discourse.julialang.org/t/how-to-handle-missingexception-in-makie/82325/2 "2022-06-06T17:15:45Z")

</div>

What is the exact call that you see this with?

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [June 6, 2022, 6:02pm UTC](https://discourse.julialang.org/t/how-to-handle-missingexception-in-makie/82325/3 "2022-06-06T18:02:41Z")

</div>

It was when I had a call like this:

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

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

```

Now I am no longer getting that error! 😄

---

<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:** [June 6, 2022, 6:07pm UTC](https://discourse.julialang.org/t/how-to-handle-missingexception-in-makie/82325/4 "2022-06-06T18:07:12Z")

</div>

Weird, this works for me:

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

```

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/5/c/5ca5140050980eb8e842c1035461b21386e656a3.png)

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [June 6, 2022, 6:07pm UTC](https://discourse.julialang.org/t/how-to-handle-missingexception-in-makie/82325/5 "2022-06-06T18:07:50Z")

</div>

This is peculiar.  
Let me double check.

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [June 6, 2022, 6:18pm UTC](https://discourse.julialang.org/t/how-to-handle-missingexception-in-makie/82325/6 "2022-06-06T18:18:09Z")

</div>

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!
