CairoMakie cant plot with plot function and range problem

I am trying to plot using below code and it is the same as tutorials. at first it couldnt recognize plot individually so i added CairoMakie at the function initials. but then it gives me the error of range couldnt be zero. can you help me?

using CairoMakie, GridapMakie
p0 = p_opt
vApp = vAppMax
pf_vec = pf_p0(p0; r, fem_params)
pfh = FEFunction(fem_params.Pf, pf_vec)
pth = (pf -> Threshold(pf; β, η)) ∘ pfh
A_mat = MatrixA(pth; fem_params)
b_vec = assemble_vector(0.0, fem_params.V0_Disp)
u_vec = A_mat \ b_vec
uh = FEFunction(fem_params.U_Disp, u_vec)

fig, ax, plt = CairoMakie.plot(fem_params.Ω, pth, colormap = :binary)
CairoMakie.Colorbar(fig[1,2], plt)
ax.aspect = AxisAspect(1)
ax.title = "Design Shape"
rplot = 110 # Region for plot
CairoMakie.limits!(ax, -rplot, rplot, (h1)/2-rplot, (h1)/2+rplot)
CairoMakie.save("shape.png", fig)

ArgumentError: range step cannot be zero

Stacktrace:
[1] (::Colon)(start::Float32, step::Float32, stop::Float32)
@ Base .\twiceprecision.jl:412
[2] get_minor_tickvalues(i::IntervalsBetween, scale::Function, tickvalues::Vector{Float32}, vmin::Float32, vmax::Float32)
@ Makie C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\lineaxis.jl:670
[3] (::Makie.var"#1179#1192"{Attributes, Observable{Vector{Float32}}, Observable{Tuple{Float32, Float32}}})(tickvalues::Vector{Float32}, minorticks::IntervalsBetween)
@ Makie C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\lineaxis.jl:394
[4] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base .\essentials.jl:729
[5] invokelatest(::Any, ::Any, ::Vararg{Any})
@ Base .\essentials.jl:726
[6] (::Observables.OnAny)(value::Any)
@ Observables C:\Users\marya.julia\packages\Observables\PHGQ8\src\Observables.jl:415
[7] #invokelatest#2
@ .\essentials.jl:729 [inlined]
[8] invokelatest
@ .\essentials.jl:726 [inlined]
[9] notify
@ C:\Users\marya.julia\packages\Observables\PHGQ8\src\Observables.jl:169 [inlined]
[10] setindex!(observable::Observable, val::Any)
@ Observables C:\Users\marya.julia\packages\Observables\PHGQ8\src\Observables.jl:86
[11] update_tickpos_string(closure_args::Tuple{Observable{Vector{AbstractString}}, Observable{Vector{GeometryBasics.Point{2, Float32}}}, Observable{Vector{Float32}}, Observable{Tuple{Float32, Tuple{Float32, Float32}, Bool}}, Observable{Tuple{Float32, Float32}}}, tickvalues_labels_unfiltered::Tuple{Vector{Float64}, Vector{String}}, reversed::Bool, scale::typeof(identity))
@ Makie C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\lineaxis.jl:191
[12] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base .\essentials.jl:729
[13] invokelatest(::Any, ::Any, ::Vararg{Any})
@ Base .\essentials.jl:726
[14] (::Observables.OnAny)(value::Any)
@ Observables C:\Users\marya.julia\packages\Observables\PHGQ8\src\Observables.jl:415
[15] #invokelatest#2
@ .\essentials.jl:729 [inlined]
[16] invokelatest
@ .\essentials.jl:726 [inlined]
[17] notify
@ C:\Users\marya.julia\packages\Observables\PHGQ8\src\Observables.jl:169 [inlined]
[18] setindex!(observable::Observable, val::Any)
@ Observables C:\Users\marya.julia\packages\Observables\PHGQ8\src\Observables.jl:86
[19] (::Observables.MapCallback)(value::Any)
@ Observables C:\Users\marya.julia\packages\Observables\PHGQ8\src\Observables.jl:431
[20] #invokelatest#2
@ .\essentials.jl:729 [inlined]
[21] invokelatest
@ .\essentials.jl:726 [inlined]
[22] notify(observable::Observables.AbstractObservable)
@ Observables C:\Users\marya.julia\packages\Observables\PHGQ8\src\Observables.jl:169
[23] Makie.LineAxis(parent::Scene, attrs::Attributes)
@ Makie C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\lineaxis.jl:434
[24] #LineAxis#1157
@ C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\lineaxis.jl:3 [inlined]
[25] initialize_block!(cb::Colorbar)
@ Makie C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\blocks\colorbar.jl:315
[26] _block(::Type{Colorbar}, ::Makie.Figure; bbox::Nothing, kwargs::Base.Pairs{Symbol, Observable{Any}, Tuple{Symbol, Symbol}, NamedTuple{(:colormap, :limits), Tuple{Observable{Any}, Observable{Any}}}})
@ Makie C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\blocks.jl:403
[27] block(::Type{Colorbar}, ::GridPosition; kwargs::Base.Pairs{Symbol, Observable{Any}, Tuple{Symbol, Symbol}, NamedTuple{(:colormap, :limits), Tuple{Observable{Any}, Observable{Any}}}})
@ Makie C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\blocks.jl:294
[28] #
#1005
@ C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\blocks.jl:279 [inlined]
[29] Colorbar(fig_or_scene::GridPosition, plot::Combined{GridapMakie.meshfield, Tuple{BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.OperationCellField{ReferenceDomain}}}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Makie C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\blocks\colorbar.jl:29
[30] Colorbar(fig_or_scene::GridPosition, plot::Combined{GridapMakie.meshfield, Tuple{BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.OperationCellField{ReferenceDomain}}})
@ Makie C:\Users\marya.julia\packages\Makie\Ppzqh\src\makielayout\blocks\colorbar.jl:21
[31] top-level scope
@ In[189]:13

i also did this for range but it gives me below error.

using CairoMakie, GridapMakie
p0 = p_opt
vApp = vAppMax
pf_vec = pf_p0(p0; r, fem_params)
pfh = FEFunction(fem_params.Pf, pf_vec)
pth = (pf -> Threshold(pf; β, η)) ∘ pfh
A_mat = MatrixA(pth; fem_params)
b_vec = assemble_vector(0.0, fem_params.V0_Disp)
u_vec = A_mat \ b_vec
uh = FEFunction(fem_params.U_Disp, u_vec)
cells = fem_params.Ω.cells

pth_array = [pth[cell] for cell in cells]
pth_min = minimum(pth_array)
pth_max = maximum(pth_array)

fig, ax, plt = CairoMakie.plot(fem_params.Ω, pth, colormap = :binary, range=(pth_min, pth_max))
CairoMakie.Colorbar(fig[1,2], plt)
ax.aspect = AxisAspect(1)
ax.title = "Design Shape"
rplot = 110 # Region for plot
CairoMakie.limits!(ax, -rplot, rplot, (h1)/2-rplot, (h1)/2+rplot)
CairoMakie.save("shape.png", fig)

type BodyFittedTriangulation has no field cells

Stacktrace:
[1] getproperty(x::BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, f::Symbol)
@ Base .\Base.jl:38
[2] top-level scope
@ In[187]:11

This is probably a float precision error. You can try scaling your data up and then manually setting tick labels to avoid this.

thank you for your response. I have tried to understand and implement your response in my code but i couldn’t. can you explain more?