# Plots -\> PgfPlotsX: Group plot only "outer edge" x and y-labels?

**URL:** <https://discourse.julialang.org/t/plots-pgfplotsx-group-plot-only-outer-edge-x-and-y-labels/48737>\
**Category:** New to Julia\
**Tags:** pgfplotsx\
**Created:** [October 21, 2020, 10:09am UTC](https://discourse.julialang.org/t/plots-pgfplotsx-group-plot-only-outer-edge-x-and-y-labels/48737 "2020-10-21T10:09:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [October 21, 2020, 10:09am UTC](https://discourse.julialang.org/t/plots-pgfplotsx-group-plot-only-outer-edge-x-and-y-labels/48737/1 "2020-10-21T10:09:18Z")

</div>

Hello!

I am using Plots with pgfplotsx(). I have made a plot which looks like:

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

Marked in yellow is the labels I would like to remove. I understand that one way to avoid these labels is by not constructing them in the first place, but I also save the plots individually, so I would just like to specify that for the group plot do not put the “inner” labels but only the outer ones, which are not marked in yellow.

Sample code to do this based on [Layouts · Plots](https://docs.juliaplots.org/latest/layouts/)

```julia
using Plots
pgfplotsx()

plot(rand(100,4), layout = 4, label=["a" "b" "c" "d"],
    title=["1" "2" "3" "4"])
xlabel!("hi")
ylabel!("bye")

```

Kind regards

---

<div class="post-metadata">

**Author:** ![daschw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daschw/32/2926_2.png) [@daschw](https://discourse.julialang.org/u/daschw)\
**Post date:** [October 21, 2020, 11:19am UTC](https://discourse.julialang.org/t/plots-pgfplotsx-group-plot-only-outer-edge-x-and-y-labels/48737/2 "2020-10-21T11:19:27Z")

</div>

You can either modify the axis labels of subplots

```julia
p = plot(
    rand(100, 4),
    layout = 4,
    label = ["a" "b" "c" "d"],
    title = ["1" "2" "3" "4"],
)
xlabel!(p[3], "hi")
xlabel!(p[4], "hi")
ylabel!(p[1], "bye")
ylabel!(p[3], "bye")

```

or specify them for each subplot in the `plot` command by passing row vectors.

```julia
p = plot(
    rand(100, 4),
    layout = 4,
    label = ["a" "b" "c" "d"],
    title = ["1" "2" "3" "4"],
    xlabel = ["" "" "hi" "hi"],
    ylabel = ["bye" "" "bye" ""],
)

```

Both result in this plot:

 ![layoutlabels](https://global.discourse-cdn.com/julialang/original/3X/e/7/e7eb604eeb619d6f13c9ca1b686e9cdf7fb7e24a.png)

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [October 21, 2020, 12:38pm UTC](https://discourse.julialang.org/t/plots-pgfplotsx-group-plot-only-outer-edge-x-and-y-labels/48737/3 "2020-10-21T12:38:05Z")

</div>

> [@daschw](#):
>
> ```julia
> xlabel!(p[3], "hi")
> xlabel!(p[4], "hi")
> 
> ```

This is a step in the right direction! Suppose I have an array defined as:

```julia
all_plots
4-element Array{Plots.Plot,1}:
 Plot{Plots.PGFPlotsXBackend() n=5}
 Plot{Plots.PGFPlotsXBackend() n=5}
 Plot{Plots.PGFPlotsXBackend() n=5}
 Plot{Plots.PGFPlotsXBackend() n=5}

```

So basically p[1], p[2] etc. How would I then select only odd/even indices, so that I could write;

```julia
xlabel!(all_plots[even_indices]," ")

```

EDIT: one simple solution I found is:

```julia
ylabel!.(all_plots[2:2:4],"")

```

Kind regards

---

<div class="post-metadata">

**Author:** ![daschw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daschw/32/2926_2.png) [@daschw](https://discourse.julialang.org/u/daschw)\
**Post date:** [October 21, 2020, 12:54pm UTC](https://discourse.julialang.org/t/plots-pgfplotsx-group-plot-only-outer-edge-x-and-y-labels/48737/4 "2020-10-21T12:54:19Z")

</div>

If I had an array `all_plots` of plots and I wanted to combine them as subplots in a layout, I would do it like this:

```julia
all_plots = [plot(rand(100)) for i in 1:4]

plot(
    all_plots..., 
    xlabel = ["" "" "hi" "hi"],
    ylabel = ["bye" "" "bye" ""],
)

```

For general layout grid sizes:

```julia
m = 5
n = 3
all_plots = [plot(rand(100)) for i in 1:m*n]

plot(
    all_plots...,
    layout = (m, n),
    xlabel = permutedims([i > (m - 1) * n ? "hi" : "" for i in 1:m*n]),
    ylabel = permutedims([mod(i, n) == 1 ? "bye" : "" for i in 1:m*n]),
)

```

---

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [October 21, 2020, 12:56pm UTC](https://discourse.julialang.org/t/plots-pgfplotsx-group-plot-only-outer-edge-x-and-y-labels/48737/5 "2020-10-21T12:56:20Z")

</div>

Awesome, I like how compact it is!

I will look into it if my situation becomes more complex.

Kind regards
