# Stat.xticks fails in presence of Geom.vband and Geom.line

**URL:** <https://discourse.julialang.org/t/stat-xticks-fails-in-presence-of-geom-vband-and-geom-line/72416>\
**Category:** Visualization\
**Tags:** gadfly\
**Created:** [December 1, 2021, 10:52pm UTC](https://discourse.julialang.org/t/stat-xticks-fails-in-presence-of-geom-vband-and-geom-line/72416 "2021-12-01T22:52:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alan/32/15970_2.png) [@alan](https://discourse.julialang.org/u/alan)\
**Post date:** [December 1, 2021, 10:52pm UTC](https://discourse.julialang.org/t/stat-xticks-fails-in-presence-of-geom-vband-and-geom-line/72416/1 "2021-12-01T22:52:22Z")

</div>

Trying to make a plot that includes Geom.line, Geom.vband, and Stat.xticks. Without Stat.xticks, it works fine. When I add Stat.xticks, I get: “Error showing value of type Plot:  
ERROR: The following aesthetics are required by RectangularBinGeometry but are not defined: ymin, ymax”

Here is a minimal example:

```julia
using Gadfly, DataFrames

df = DataFrame(x = 0:10, y = (0:10) .^ 2)

tickpos = [x for x in 0:2:8] # tick positions

linelyr = layer(df, x=:x, y=:y, Geom.line)

dr = DataFrame(s=[1, 4], e=[3, 5])

rectlyr = layer(dr, xmin=:s, xmax=:e, Geom.vband,
                color=[colorant"deepskyblue"], alpha=[0.5])

plot(linelyr, rectlyr, Stat.xticks(ticks = tickpos))

```

I thought I would post here before reporting this as a bug, I suspect the error is mine.

---

<div class="post-metadata">

**Author:** ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)\
**Post date:** [December 2, 2021, 1:57am UTC](https://discourse.julialang.org/t/stat-xticks-fails-in-presence-of-geom-vband-and-geom-line/72416/2 "2021-12-02T01:57:08Z")

</div>

Yes, you want `plot(linelyr, rectlyr, Guide.xticks(ticks=tickpos))`. In your example above, the free-standing Stat (`Stat.xticks`) gets added to the newest layer. This is documented in the Layers section of the docs: [Compositing · Gadfly.jl](http://gadflyjl.org/stable/man/compositing/#Layers). Hence it would also work if you moved `Stat.xtcks` between the 2 layers!
