Skip to content

Commit

Permalink
plot expfits changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aris committed Nov 28, 2024
1 parent 6c0cc91 commit a6f9f45
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions ext/gui_ext.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ e.g. `plot(data1)` plots the data and the corresponding fit,
but `plot(data1, data2)` or `plot(data1, data2, data3)` work as well,
and they plot all of the results on the same plot.
This function creates a figure,
and calls `plot!(fig, res)` for each of the results in `res`,
so please refer to the `plot!` documentation for more information.
Keyword (optional) arguments:
- `markersize` : The size of the markers (default is 7).
- `normeq` : Whether to plot the normalised form of the equation or not (default is `true`).
- `yscale` : The scale of the y-axis (default is `identity`).
"""
function Makie.plot(res::expfit_struct...; kwargs...)

Expand All @@ -26,6 +28,16 @@ function Makie.plot(res::expfit_struct...; kwargs...)

end

function Makie.plot(res_mat::AbstractVecOrMat{NMRInversions.expfit_struct}; kwargs...)

f = Figure(size=(800, 400))
plot!(f, res_mat...; kwargs...)

return f

end
end

"""
plot!(fig, res...; names, markersize, normeq)
Expand All @@ -39,24 +51,25 @@ The arguments are:
Keyword (optional) arguments:
- `markersize` : The size of the markers (default is 7).
- `normeq` : Whether to plot the normalised form of the equation or not (default is `true`).
- `yscale` : The scale of the y-axis (default is `identity`).
Note that the res inputs are not a vector, but individual `expfit_struct` structures,
like: plot!(fig, data1, data2, data3).
If you want to use a vector of `expfit_struct` structures, make sure to
splat it by using `...` in the function call (e.g. `plot!(fig, [data1, data2, data3]...)`).
"""
function Makie.plot!(fig::Union{Makie.Figure,Makie.GridPosition}, res::expfit_struct...;
markersize=7, normeq=true)
markersize=7, normeq=true, yscale = identity)

# Make axes
if res[1].seq in [NMRInversions.IR]
ax = Axis(fig[1, 1], xlabel="time (s)", ylabel="Signal (a.u.)")
ax = Axis(fig[1, 1], xlabel="time (s)", ylabel="Signal (a.u.)",yscale=yscale)

elseif res[1].seq in [NMRInversions.CPMG]
ax = Axis(fig[1, 1], xlabel="time (s)", ylabel="Signal (a.u.)")
ax = Axis(fig[1, 1], xlabel="time (s)", ylabel="Signal (a.u.)",yscale=yscale)

elseif res[1].seq in [NMRInversions.PFG]
ax = Axis(fig[1, 1], xlabel="b factor (s/m² e-9)", ylabel="Signal (a.u.)")
ax = Axis(fig[1, 1], xlabel="b factor (s/m² e-9)", ylabel="Signal (a.u.)",yscale=yscale)
end

for (i, r) in enumerate(res)
Expand Down

0 comments on commit a6f9f45

Please sign in to comment.