# CairoMakie returning empty plots

**URL:** <https://discourse.julialang.org/t/cairomakie-returning-empty-plots/72581>\
**Category:** Visualization\
**Tags:** question, makie\
**Created:** [December 4, 2021, 3:15pm UTC](https://discourse.julialang.org/t/cairomakie-returning-empty-plots/72581 "2021-12-04T15:15:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hiraksarkar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hiraksarkar/32/31444_2.png) [@hiraksarkar](https://discourse.julialang.org/u/hiraksarkar)\
**Post date:** [December 4, 2021, 3:15pm UTC](https://discourse.julialang.org/t/cairomakie-returning-empty-plots/72581/1 "2021-12-04T15:15:16Z")

</div>

Hi,

I am new to julia, I want plot a simple scatterplot from a dataframe where the colors are coded as String7 hexadecimal code, a snapshot,

```julia
Row │ x y ncv_color 
     │ Int64 Int64 String7   
─────┼─────────────────────────
   1 │ 120 4180 #005529
   2 │ 120 3890 #004903
   3 │ 110 4670 #004E66
   4 │ 120 8270 #004A99
   5 │ 120 9620 #005C5A

```

when I use the following code to draw a scatterplot, it works.

```julia
scatter(df.x, df.y)

```

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

Although when I use

```julia
scatter(df2.x, df2.y, color=:ncv_color)

```

I get `FigureAxisPlot()` as output and no plot is shown.

Any help would be appreciated.

`versioninfo`

```julia
Julia Version 1.6.3
Commit ae8452a9e0 (2021-09-23 17:34 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: AMD EPYC 7542 32-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, znver2)

```

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [December 6, 2021, 9:02am UTC](https://discourse.julialang.org/t/cairomakie-returning-empty-plots/72581/2 "2021-12-06T09:02:09Z")

</div>

Welcome @hiraksarkar  
So far you didn’t get any response, probably because it would be much easier to look for a solution if you would provide some MWE (see [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757)).  
Despite that there are some obvious issues: you use `df2` in the second scatter plot instead of `df` and strings as colors do probably not work per se, they need to be converted, and it should be `color=df.ncv_color`, or `df2.color` it `df2` was intentional.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [December 6, 2021, 9:27am UTC](https://discourse.julialang.org/t/cairomakie-returning-empty-plots/72581/3 "2021-12-06T09:27:01Z")

</div>

this works:

```julia
color = ["#005529", "#004903", "#004E66", "#004A99", "#005C5A"]
df = DataFrame(x = rand(5), y = rand(5), ncv_color = color)
scatter(df.x, df.y; color = df.ncv_color, markersize = 15)

```

yours should also.

---

<div class="post-metadata">

**Author:** ![hiraksarkar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hiraksarkar/32/31444_2.png) [@hiraksarkar](https://discourse.julialang.org/u/hiraksarkar)\
**Post date:** [December 6, 2021, 1:18pm UTC](https://discourse.julialang.org/t/cairomakie-returning-empty-plots/72581/4 "2021-12-06T13:18:03Z")

</div>

@oheil , @lazarusA Thanks a lot for the reply.

@oheil The `df2` was a typo. So colors as strings seem to work as @lazarusA demonstrated. The problem in my code was `String7` that does not work with `Makie` color plot.

The following conversion worked

```julia
df.ncv_color = convert(Vector{String}, df.ncv_color)

```

---

<div class="post-metadata">

**Author:** ![hiraksarkar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hiraksarkar/32/31444_2.png) [@hiraksarkar](https://discourse.julialang.org/u/hiraksarkar)\
**Post date:** [December 6, 2021, 1:20pm UTC](https://discourse.julialang.org/t/cairomakie-returning-empty-plots/72581/5 "2021-12-06T13:20:41Z")

</div>

`String` works, `String7` does not.

---

<div class="post-metadata">

**Author:** ![hiraksarkar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hiraksarkar/32/31444_2.png) [@hiraksarkar](https://discourse.julialang.org/u/hiraksarkar)\
**Post date:** [December 6, 2021, 1:21pm UTC](https://discourse.julialang.org/t/cairomakie-returning-empty-plots/72581/6 "2021-12-06T13:21:24Z")

</div>

`df2` is a typo, should be `df`
