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:
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:
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
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?