# VegaLite: Facet plots with independent scales for histograms

**URL:** https://discourse.julialang.org/t/vegalite-facet-plots-with-independent-scales-for-histograms/42464
**Category:** Visualization
**Tags:** plotting
**Created:** [July 3, 2020, 8:27am UTC](https://discourse.julialang.org/t/vegalite-facet-plots-with-independent-scales-for-histograms/42464 "2020-07-03T08:27:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![hellemo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hellemo/32/324_2.png) [@hellemo](https://discourse.julialang.org/u/hellemo)
#### Post date: [July 3, 2020, 8:27am UTC](https://discourse.julialang.org/t/vegalite-facet-plots-with-independent-scales-for-histograms/42464/1 "2020-07-03T08:27:13Z")

</div>

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?

```julia
using VegaLite,VegaDatasets
dataset("cars") |>
@vlplot(
    :bar,
    x={
        :Horsepower,
        bin={maxbins=15}
    },
    y="count()",
    column=:Origin,
    resolve={scale={x="independent",y="independent"}}
)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/f/4f9409ac172542fdea590e4fff832077ec14f33b.png)

EDIT2:  
[python - altair faceted histogram - independent scales - Stack Overflow](https://stackoverflow.com/questions/60839767/altair-faceted-histogram-independent-scales) suggests it indeed has to do with the binning.

I hacked this together, but hope there is a better way to do it:

```julia
   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)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/9/79da87c20e4beee178b13c513febb40e688c2128.png)

```julia
  [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

```
