Vegalite.jl Linear Fitting & Question of Controlling Interface

What is the easiest most basic example of quickly fitting to a simple scatterplot using Vegalite.jl? (Say, with two columns of some numbers.)

My other question is whether there are any plans to again have that higher general interface (I believe its name is Plots) to steer Vegalite.jl like it steers other vis. packages.

If you can use VegaLite#master this is an example which is probably not the simplest one but you may adapt it to your needs:

using VegaLite, VegaDatasets

dataset("movies") |>
@vlplot(
layer=[{
    mark={:point,filled=true},
    x="Rotten_Tomatoes_Rating:q",
    y="IMDB_Rating:q"
},
{
    transform=[
        {
            regression="IMDB_Rating",
            on="Rotten_Tomatoes_Rating"
        }
    ],
    mark={:line,color="firebrick"},
    x="Rotten_Tomatoes_Rating:q",
    y="IMDB_Rating:q"
},
{
    transform=[
        {
            regression="IMDB_Rating",
            on="Rotten_Tomatoes_Rating",
            params=true
        },
        {
            calculate="'R²: '+format(datum.rSquared, '.2f')",
            as="R2"
        }
    ],
    mark={:text,color="firebrick",x="width",align="right",y=-5},
    text={"R2:n"}
}]
)

It is an adaption of

Using the Julia way of layers with ) + @vlplot( doesnt work and I didn’t found out why yet.

1 Like

There is also hope that at some point we will get an even easier syntax for this scenario, see this issue on the original vega-lite repo.

1 Like

Thanks for your responses.

Your opening of that issue, David, seems indeed in order. A concise simple way would be indeed preferrable.

(And I suppose for the moment that that concise general and overarching Plots support for Vegalite.jl will not exist. I recall an answer where it was said that Vegalite.jl is for manual and specific control anyway. But certainly there is good value in that overarching support.)