I would like to do a facet plot with independent scales for the x-axis, but can’t get it to work. It works for the y-axis though. Any ideas?
EDIT: I tried switching the axes to no avail, so it seems it has to do with the binning?
using VegaLite,VegaDatasets
dataset("cars") |>
@vlplot(
:bar,
x={
:Horsepower,
bin={maxbins=15}
},
y="count()",
column=:Origin,
resolve={scale={x="independent",y="independent"}}
)
EDIT2:
python - altair faceted histogram - independent scales - Stack Overflow suggests it indeed has to do with the binning.
I hacked this together, but hope there is a better way to do it:
ds = DataFrame(dataset("cars"))
hs = [ds[ds.Origin .== o,:] |>
@vlplot(
:bar,
x={
:Horsepower,
bin={maxbins=15}
},
y="count()",
column=:Origin,
resolve={scale={x="independent",y="independent"},
axis={x="independent"}}
) for o in unique(ds.Origin)]
@vlplot() + reduce(hcat,hs)
[0ae4a718] VegaDatasets v2.1.0
[112f6efa] VegaLite v2.2.0
Julia Version 1.5.0-rc1.0
Commit 24f033c951 (2020-06-26 20:13 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 4
JULIA_PKG_SERVER = pkg.julialang.org