using GLMakie
n = 20
θ = [0;(0.5:n-0.5)/n;1]
φ = [(0:2n-2)*2/(2n-1);2]
x = [cospi(φ)*sinpi(θ) for θ in θ, φ in φ]
y = [sinpi(φ)*sinpi(θ) for θ in θ, φ in φ]
z = [cospi(θ) for θ in θ, φ in φ]
surface(x, y, z)

I want to plot 3-D cylinder, like this

Which equations of cylinder should I use? So I am able to plot it 3-dimensionally like the sphere above

I have been trying this code but fail to create a cylinder:

using GLMakie
GLMakie.activate!()
set_theme!(backgroundcolor = :white)
# A cylinder of radius r, and height h, having z-axis as symmetry axis
# it is a stack of circles of radius r
r = 5
h = 3
n = 50
θ = LinRange(0, 2pi, 100)
#θ = [0;(0.5:n-0.5)/n;2π]
v = [0;(1:n)/n;h]
x = [r*cos(θ) for θ in θ]
y = [r*sin(θ) for θ in θ]
z = [v for v in v]
surface(x, y, z)

Your code doesn’t generate a surface, because x, y, z are vectors, but for a parameterized surface they should be matrices:

using Plots
plotlyjs()
r = 5
h = 3
m, n =200, 150
u = range(0, 2pi, length=n)
v = range(0, h, length=m)
us = ones(m)*u'
vs = v*ones(n)'
#Surface parameterization
X = r*cos.(us)
Y = r*sin.(us)
Z = vs
Plots.surface(X, Y, Z, size=(600,600), cbar=:none, legend=false)