Skip to content
Snippets Groups Projects
Verified Commit 92e995c4 authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

Add cleaner plot_sequence function

parent 3c9419c7
No related branches found
No related tags found
No related merge requests found
module MakieMRIBuilder
using Makie
import MakieCore
import MRIBuilder.Plot: Plot_Sequence, SequenceDiagram, range_line, normalise
import MakieCore: @recipe, theme, generic_plot_attributes!, Attributes, automatic
import MRIBuilder.Plot: SequenceDiagram, range_line, normalise, plot_sequence
import MRIBuilder: BaseSequence, BaseBuildingBlock, duration
@recipe(Plot_Sequence, sequence) do scene
attr = Attributes(
color = theme(scene, :textcolor),
linecolor = automatic,
linewidth = 1.5,
instant_width = 3.,
textcolor = automatic,
font = theme(scene, :font),
fonts = theme(scene, :fonts),
fontsize = theme(scene, :fontsize),
fxaa = true,
)
generic_plot_attributes!(attr)
return attr
end
function Makie.plot!(scene:: Plot_Sequence)
kwargs = Dict([
key => scene[key] for key in [
......@@ -42,4 +60,15 @@ end
Makie.plottype(::Union{BaseBuildingBlock, BaseSequence}) = Plot_Sequence
function plot_sequence(sequence; figure=(), axis=(xgridvisible=false, ygridvisible=false), kwargs...)
f = Figure(; figure...)
ax = Axis(f[1, 1]; axis...)
p = plot!(ax, sequence; kwargs...)
ax.xlabel[] = "Time (ms)"
hideydecorations!(ax)
hidespines!(ax, :l, :r, :t)
return Makie.FigureAxisPlot(f, ax, p)
end
end
\ No newline at end of file
......@@ -38,6 +38,9 @@ export dwi_gradients, readout_event, excitation_pulse, refocus_pulse, Trapezoid,
import .Sequences: GradientEcho, SpinEcho, DiffusionSpinEcho, DW_SE, DWI
export GradientEcho, SpinEcho, DiffusionSpinEcho, DW_SE, DWI
import .Plot: plot_sequence
export plot_sequence
import JuMP: @constraint, @objective, objective_function, value, Model
export @constraint, @objective, objective_function, value, Model
......
module Plot
import MakieCore: @recipe, theme, generic_plot_attributes!, Attributes, automatic, shading_attributes!, colormap_attributes!
import MakieCore: generic_plot_attributes!
import ..Containers: BaseBuildingBlock, BaseSequence, waveform, events, start_time, ndim_grad, waveform_sequence
import ..Variables: duration, flip_angle, phase, make_generic, gradient_orientation
import ..Components: RFPulseComponent, ADC, InstantPulse, NoGradient
......@@ -159,15 +159,19 @@ function normalise(sd::SequenceDiagram)
)
end
"""
plot(sequence; kwargs...)
plot!([scene,] sequence; kwargs...)
plot_sequence(sequence; kwargs...)
plot_sequence!([scene,] sequence; kwargs...)
plot_sequence(sequence; figure=(), axis=(), attributes...)
plot(sequence; attributes...)
plot!([scene,] sequence; attributes...)
Plot the sequence diagram.
Calling `plot_sequence` will result in a much cleaner sequence diagram (recommended).
However, if you want to combine this diagram with other plots you will have to use `plot` or `plot!` instead.
If called as `plot_sequence` the user can also supply `Makie.Figure` (`figure=(...)`) and `Makie.Axis` (`axis=(...)`) keywords.
If called using the `plot` or `plot!` interface, only the attributes listed below can be supplied
This function will only work if [`Makie`](https://makie.org) is installed and imported.
## Attributes
......@@ -184,20 +188,6 @@ This function will only work if [`Makie`](https://makie.org) is installed and im
$(Base.Docs.doc(generic_plot_attributes!))
"""
@recipe(Plot_Sequence, sequence) do scene
attr = Attributes(
color = theme(scene, :textcolor),
linecolor = automatic,
linewidth = 1.5,
instant_width = 3.,
textcolor = automatic,
font = theme(scene, :font),
fonts = theme(scene, :fonts),
fontsize = theme(scene, :fontsize),
fxaa = true,
)
generic_plot_attributes!(attr)
return attr
end
function plot_sequence end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment