# How can I use strings containing whitespace in VegaLite?

**URL:** <https://discourse.julialang.org/t/how-can-i-use-strings-containing-whitespace-in-vegalite/76648>\
**Category:** General Usage\
**Tags:** question, vegalite\
**Created:** [February 17, 2022, 7:14pm UTC](https://discourse.julialang.org/t/how-can-i-use-strings-containing-whitespace-in-vegalite/76648 "2022-02-17T19:14:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Post date:** [February 17, 2022, 7:14pm UTC](https://discourse.julialang.org/t/how-can-i-use-strings-containing-whitespace-in-vegalite/76648/1 "2022-02-17T19:14:41Z")

</div>

I want to create a heatmap using VegaLite. That is not hard to do if the name of the column containing the numeric data is well-behaved. This chart looks good:

```julia
using DataFrames, VegaLite

df = DataFrame(
  "AA" => rand(10),
  "B C" => [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],
  "D" => [0, 1, 0, 1, 0, 1, 0, 1, 0, 1,]
)

df |> @vlplot(
    :rect,
    x = {field="B C", type="nominal"},
    y = {field="D", type="nominal"},
    color="mean(AA)",
    width = 600,
    height = 600
)

```

But I was not able to do it when the name of the numeric column contains spaces. The chart produced by this code is blank:

```julia
df = DataFrame(
  "A A" => rand(10),
  "B C" => [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],
  "D" => [0, 1, 0, 1, 0, 1, 0, 1, 0, 1,]
)

df |> @vlplot(
    :rect,
    x = {field="B C", type="nominal"},
    y = {field="D", type="nominal"},
    color="mean(A A)",
    width = 600,
    height = 600
)

```

I tried quite a few things like

```julia
saa = symbol("A A")
df = DataFrame(
  saa => rand(10),
  :BC => [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],
  :D => [0, 1, 0, 1, 0, 1, 0, 1, 0, 1,]
)

df |> @vlplot(
    :rect,
    x = {field=:BC, type="nominal"},
    y = {field=:D, type="nominal"},
    color="mean(saa)",
    width = 600,
    height = 600
)

```

but nothing worked. Any suggestions?

---

<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:** [February 17, 2022, 9:18pm UTC](https://discourse.julialang.org/t/how-can-i-use-strings-containing-whitespace-in-vegalite/76648/2 "2022-02-17T21:18:22Z")

</div>

```julia
julia> df |> @vlplot(
           :rect,
           x = {field="B C", type="nominal"},
           y = {field="D", type="nominal"},
           color = { aggregate="mean", field="A A" },
           width = 600,
           height = 600
       )

```

---

<div class="post-metadata">

**Author:** ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Post date:** [February 18, 2022, 2:48am UTC](https://discourse.julialang.org/t/how-can-i-use-strings-containing-whitespace-in-vegalite/76648/3 "2022-02-18T02:48:33Z")

</div>

Thanks. It works.
