From 4d5d7761ad0ecc9ee64acb96424c87608245fb37 Mon Sep 17 00:00:00 2001 From: Michiel Cottaar <michiel.cottaar@ndcn.ox.ac.uk> Date: Mon, 26 Feb 2024 11:26:12 +0000 Subject: [PATCH] Add plotting function if Makie is installed --- Project.toml | 1 + src/plot.jl | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/Project.toml b/Project.toml index 321acf7..a4ea3ed 100644 --- a/Project.toml +++ b/Project.toml @@ -8,6 +8,7 @@ Ipopt = "b6b21f68-93f8-5de0-b562-5493be1d77c9" JuMP = "4076af6c-e467-56ae-b986-b466b2749572" Juniper = "2ddba703-00a4-53a7-87a5-e8b9971dde84" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +MakieCore = "20f20a25-4f0e-4fdf-b5d1-57303727442b" Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" diff --git a/src/plot.jl b/src/plot.jl index 2215964..ba638de 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -130,4 +130,45 @@ function SequenceDiagram(seq::BaseSequence) for symbol in [:RFx, :RFy, :G, :Gx, :Gy, :Gz, :ADC]]...) end + +""" + plot(sequence; kwargs...) + plot!([scene,] sequence; kwargs...) + plot_sequence(sequence; kwargs...) + plot_sequence!([scene,] sequence; kwargs...) + +Plot the sequence diagram. + +This function will only work if [`Makie`](https://makie.org) is installed and imported. + +## Attributes + +### Line properties +- `linecolor` sets the color of the lines. If you want to set the text color to the same value, you can also use `color=...`. +- `linewidth=1.5` sets the width of the lines. +- `instant_width=3.` sets the width of any instant gradients or pulses with respect to the `linewidth`. + +### Text properties +- `textcolor` sets the color of the text. If you want to set the line color to the same value, you can also use `color=...`. +- `font` sets whether the rendered text is :regular, :bold, or :italic. +- `fontsize`: set the size of each character. + +$(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 + end \ No newline at end of file -- GitLab