# Subplots in Plots.jl with individual axis labels

**URL:** <https://discourse.julialang.org/t/subplots-in-plots-jl-with-individual-axis-labels/8462>\
**Category:** New to Julia\
**Tags:** question, plotting\
**Created:** [January 18, 2018, 7:15pm UTC](https://discourse.julialang.org/t/subplots-in-plots-jl-with-individual-axis-labels/8462 "2018-01-18T19:15:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgiugliano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgiugliano/32/5818_2.png) [@mgiugliano](https://discourse.julialang.org/u/mgiugliano)\
**Post date:** [January 18, 2018, 7:15pm UTC](https://discourse.julialang.org/t/subplots-in-plots-jl-with-individual-axis-labels/8462/1 "2018-01-18T19:15:42Z")

</div>

How do I specify - in the example below - the y-labels individually for the two subplots?

I am having a hard time finding just a single example of subplot where the xlabel and ylabel have been used/demonstrated.

Tnx!!!  
MG

```julia
using Plots

gr(size=(400,400), legend= false)

x = 0:100
y = x.^2
z = sqrt.(x)

l = @layout([a;b])
plot(x, [y z], layout=l, xlabel="x", ylabel="y")

```

---

<div class="post-metadata">

**Author:** ![JackDevine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jackdevine/32/1048_2.png) [@JackDevine](https://discourse.julialang.org/u/JackDevine)\
**Post date:** [January 18, 2018, 9:11pm UTC](https://discourse.julialang.org/t/subplots-in-plots-jl-with-individual-axis-labels/8462/2 "2018-01-18T21:11:51Z")

</div>

I tend to build the plots separately and bring them all together at the end.

```julia
using Plots

gr(size=(400,400), legend=false)

x = 0:100
y = x.^2
z = sqrt.(x)

p1 = plot(x, y)
xaxis!("x")
yaxis!("y")

p2 = plot(x, z)
xaxis!("Another x")
yaxis!("Another y")

plot(p1, p2, layout=(2,1))

```

I quite like this approach, because I get to look at all of the subplots individually before I put them all together.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [January 19, 2018, 4:34am UTC](https://discourse.julialang.org/t/subplots-in-plots-jl-with-individual-axis-labels/8462/3 "2018-01-19T04:34:52Z")

</div>

You can put two strings for ylabel in a 1x2 matrix just as you provided the y-series

---

<div class="post-metadata">

**Author:** ![mgiugliano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgiugliano/32/5818_2.png) [@mgiugliano](https://discourse.julialang.org/u/mgiugliano)\
**Post date:** [January 19, 2018, 6:58pm UTC](https://discourse.julialang.org/t/subplots-in-plots-jl-with-individual-axis-labels/8462/4 "2018-01-19T18:58:02Z")

</div>

Thank you JackDevine!  
Very nice and simple! Much much better (i.e. more intuitive) than what I had finally managed to dig up:

```nohighlight

p.spmap[:a][:yaxis].d[:guide] = "z"
p.spmap[:b][:yaxis].d[:guide] = "y"

```

Thank you baggepinnen, I initially tried but used the wrong syntax:

```julia
plot(x, [y z], layout=l, xlabel="x", ylabel=["z" "y"])

```

works too!

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [January 19, 2018, 7:08pm UTC](https://discourse.julialang.org/t/subplots-in-plots-jl-with-individual-axis-labels/8462/5 "2018-01-19T19:08:31Z")

</div>

Well spotted, both `group` and the “horizontal concatenation” syntax (like `[x y]`) create several `series`. If `layout == 1` they are plotted together with different colors, otherwise they are distributed across subplots.
