# Shared axis labels

**URL:** https://discourse.julialang.org/t/shared-axis-labels/97253
**Category:** New to Julia
**Tags:** question, plotting
**Created:** [April 8, 2023, 6:59pm UTC](https://discourse.julialang.org/t/shared-axis-labels/97253 "2023-04-08T18:59:21Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![KZ-Spectra](https://avatars.discourse-cdn.com/v4/letter/k/2acd7d/32.png) [@KZ-Spectra](https://discourse.julialang.org/u/KZ-Spectra)
#### Post date: [April 8, 2023, 6:59pm UTC](https://discourse.julialang.org/t/shared-axis-labels/97253/1 "2023-04-08T18:59:21Z")

</div>

I have a surface and contour plot who share the same `x` and `y` labels. The surface plot has a `z` label. In my attempt, the labels on the surface plot are not shown. Why?

Plotting code

```julia
p1 = surface(sol.t, x, z, zlabel="|u|²", colorbar = false)
p2 = contourf(sol.t,x,z)

plt = plot(p1,p2,layout=(1,2),xlabel="Time",ylabel="Space",size=(1200,700))

```

Full MWE:

```julia
using DifferentialEquations, LinearAlgebra, Plots, SparseArrays
plotlyjs()

N₁=31 # Number of waveguides / size of solution vector
γ=-1 # Nonlinear term strength parameter
h=0.4 # Grid spacing 

centerGrid = (N₁-1)/2;
x = -centerGrid:centerGrid;

# Coefficient matrix of second-order centered-difference operator (δ²u)ₙ
M = spdiagm(-1 => fill(1,N₁-1), 0 => fill(-2,N₁), 1 => fill(1,N₁-1))
M[N₁,1] = 1; # Periodic boundary conditions
M[1,N₁] = 1;

# RHS of DNLS. The solution vector u is a N₁x1 complex vector
g₁(u,p,t) = 1*im*(p[1]*M*u + @.(γ*((abs(u))^2).*u) )

# Julia is explicitly typed (e.g, cannot have Int and Complex in same array) and so we must convert the object containing the initial data to be complex
u0 = Complex.(sech.(x))

tspan = (0.0,100)
prob = ODEProblem(g₁,u0,tspan, [h])
sol = solve(prob, Tsit5(), reltol=1e-8, abstol=1e-8)

z= [abs(sol.u[i][j])^2 for j=1:N₁, i=1:size(sol)[2]] # |u|²

p1 = surface(sol.t, x, z, zlabel="|u|²", colorbar = false)
p2 = contourf(sol.t,x,z)
plt = plot(p1,p2,layout=(1,2),xlabel="Time",ylabel="Space",size=(1200,700))

```
