VegaLite vlplot basic usage, encoding

I’m new to both Vega Lite and VegaLite.jl, and I’m confused about exactly how is vlplot supposed to work. The VegaLite documentation seems to consist mostly of examples and lacks a more systematic approach to documentation, so I’m having a hard time figuring out the thing that’s confusing me here. (The @vlplot macro is confusing me even more than vlplot, because it doesn’t use Julia syntax, so I would prefer not to use it.)

This is the first example for the “Point” Vega Lite “mark” in the docs, it plots a dot plot:

  "data": {"url": "data/movies.json"},
  "mark": "point",
  "encoding": {
    "x": {"field": "IMDB Rating", "type": "quantitative"}

This is my initial snippet, basically an attempt at a straightforward adaptation of the dot plot example from Vega Lite to vlplot:

using IndexedTables, VegaLite
data = Float64[3.3, 3.4, 3.41, 3.9]
tab = table((index = (1:length(data)), values = data), pkey=:index, presorted=true)
pl = vlplot(data = tab, mark = :point, encoding = (x = (field = :values, type = :quantitative)))

The above produces just a single dot instead of dot plot, even though it seems like it should “naturally” work. But the below correction works as expected:

pl = vlplot(data = tab, mark = :point, x = (field = :values, type = :quantitative))

From this I would conclude that a Vega Lite encoding has to be specified “inline” in VegaLite.jl, except that the VegaLite documentation actually has some examples where @vlplot is given an encoding argument just like here. (E.g., here: The @vlplot command · VegaLite.jl)

So I don’t really get what’s wrong with my initial example. Can somebody help me understand?

Your assumption that function vlplot can just be used instead of macro @vlplot is wrong. The docs Home · VegaLite.jl don’t mention the function at all, so it’s clearly recommended to use the macro.
With that translation is straightforward, at least for this simple example:

pl = @vlplot(
	data = tab, 
	mark = :point, 
	encoding = {
		x = {
			field = :values, 
			type = :quantitative
1 Like