# How to make Stat.x\_jitter work with Geom.subplot\_grid

**URL:** <https://discourse.julialang.org/t/how-to-make-stat-x-jitter-work-with-geom-subplot-grid/80152>\
**Category:** Visualization\
**Tags:** gadfly\
**Created:** [April 27, 2022, 4:58pm UTC](https://discourse.julialang.org/t/how-to-make-stat-x-jitter-work-with-geom-subplot-grid/80152 "2022-04-27T16:58:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkmalaiya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rkmalaiya/32/31236_2.png) [@rkmalaiya](https://discourse.julialang.org/u/rkmalaiya)\
**Post date:** [April 27, 2022, 4:58pm UTC](https://discourse.julialang.org/t/how-to-make-stat-x-jitter-work-with-geom-subplot-grid/80152/1 "2022-04-27T16:58:23Z")

</div>

Hello Everyone,

The plot, using Gadfly.jl, that I am trying to make requires me to jitter the points in a grid plot. But I cannot figure out how? The code example below replicates my situation. Please suggest what may I be missing?

**Fake Data:**

> df\_plot = DataFrame(  
> model = repeat([“M1”,“M2”, “M3”, “M4”, “M5”, “M6”,“M7”,“M8”],inner=5),  
> metric = repeat([“Me1”,“Me2”, “Me3”, “Me4”],outer=10),  
> sample = repeat(1:2,outer=20),  
> value=rand(40)  
> )  
> ![image](https://global.discourse-cdn.com/julialang/original/3X/6/e/6ec58cffe89b89e0f24aa14048840f165d71b453.png)

**A plot with jitter but without a grid**  
I am putting this plot here to show how the jitter looks in my data  
_Code_

> Gadfly.plot(df\_plot,  
> x=:sample,  
> color = :model,  
> y=:value,  
> Geom.point, Stat.x\_jitter(range=0.4),  
> Scale.x\_discrete  
> )

_Plot_  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/3/33cd02127415f60b79f81c59b570b9d53247dd21.png)

**Now, if I add Geom.subplot\_grid, the jitter functionality seems to stop working**  
_Code_

```julia
Gadfly.plot(df_plot,
x=:sample,
color = :model,
xgroup = :metric, # Added this new parameter
y=:value,
Geom.subplot_grid(Geom.point, Stat.x_jitter(range=0.4), 
free_x_axis = true), #Updated to subplot_grid
Scale.x_discrete
)

```

_Plot_  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/3/239e5a2e069f4f0538157b481046b7329af6a03a.png)

I also tried to put x\_jitter out of subplot\_grid, but it doesn’t work! Please advise.

> Stat.x\_jitter(range=0.2),  
> Geom.subplot\_grid(Geom.point,  
> free\_x\_axis = true), #Updated to subplot\_grid

---

<div class="post-metadata">

**Author:** ![rkmalaiya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rkmalaiya/32/31236_2.png) [@rkmalaiya](https://discourse.julialang.org/u/rkmalaiya)\
**Post date:** [May 10, 2022, 11:01am UTC](https://discourse.julialang.org/t/how-to-make-stat-x-jitter-work-with-geom-subplot-grid/80152/2 "2022-05-10T11:01:32Z")

</div>

Please refer to the discussions in [github #1516](https://github.com/GiovineItalia/Gadfly.jl/issues/1516) for further updates on this issue.
