Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions docs/src/lib/plotting.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Pages = ["plotting.md"]
!!! note "Time-domain responses"
There are no special functions to plot time-domain results, such as step and impulse responses, instead, simply call `plot` on the result structure (`ControlSystemsBase.SimResult`) returned by [`lsim`](@ref), [`step`](@ref), [`impulse`](@ref) etc.


# Plotting functions

```@autodocs
Expand Down Expand Up @@ -115,3 +116,49 @@ res = step(sysd, 5)
plot(res, l=(:dash, 4))
# plot!(stepinfo(step(sysd[1,1], 5))) # adds extra info to the plot
```


## Makie support
!!! danger "Experimental"

The support for plotting with Makie is currently experimental and at any time subject to breaking changes or removal **not** respecting semantic versioning.

ControlSystemsBase provides experimental support for plotting with [Makie.jl](https://docs.makie.org/) through the `CSMakie` module. This support is loaded automatically when you load a Makie backend (GLMakie, CairoMakie, or WGLMakie).

### Usage

```julia
using ControlSystemsBase, GLMakie # or CairoMakie, WGLMakie

# Create a system
P = tf([1], [1, 2, 1])

# Use CSMakie plotting functions
CSMakie.bodeplot(P)
CSMakie.nyquistplot(P)
CSMakie.pzmap(P)
# ... and more

# Direct plotting of simulation results
res = step(P, 10)
plot(res) # Creates a figure with time-domain response

si = stepinfo(res)
plot(si) # Visualizes step response characteristics
```

### Available functions

The `CSMakie` module provides Makie implementations of the following plotting functions:

- `CSMakie.bodeplot` - Bode magnitude and phase plots
- `CSMakie.nyquistplot` - Nyquist plots with optional M and Mt circles
- `CSMakie.sigmaplot` - Singular value plots
- `CSMakie.marginplot` - Gain and phase margin plots
- `CSMakie.pzmap` - Pole-zero maps
- `CSMakie.nicholsplot` - Nichols charts
- `CSMakie.rgaplot` - Relative gain array plots
- `CSMakie.rlocusplot` - Root locus plots
- `CSMakie.leadlinkcurve` - Lead-link design curves

Additionally, `SimResult` and `StepInfo` types can be plotted directly using Makie's `plot` function.
7 changes: 6 additions & 1 deletion lib/ControlSystemsBase/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
ImplicitDifferentiation = "57b37032-215b-411a-8a7c-41a003a55207"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"

[extensions]
ControlSystemsBaseDSPExt = ["DSP"]
ControlSystemsBaseImplicitDifferentiationExt = ["ImplicitDifferentiation", "ComponentArrays"]
ControlSystemsBaseMakieExt = ["Makie"]

[compat]
Aqua = "0.5"
Expand All @@ -37,6 +39,7 @@ Hungarian = "0.7.0"
ImplicitDifferentiation = "0.7.2"
LinearAlgebra = "<0.0.1, 1"
MacroTools = "0.5"
Makie = "0.24"
MatrixEquations = "1, 2.1"
MatrixPencils = "1.8.3"
Polynomials = "3.0, 4.0"
Expand All @@ -50,17 +53,19 @@ julia = "1.6"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
GenericSchur = "c145ed77-6b09-5dd9-b285-bf645a82121e"
ImplicitDifferentiation = "57b37032-215b-411a-8a7c-41a003a55207"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Aqua", "ComponentArrays", "Documenter", "DSP", "FiniteDifferences", "ImplicitDifferentiation", "GenericSchur", "GR", "Plots", "SparseArrays", "StaticArrays"]
test = ["Test", "Aqua", "ComponentArrays", "Documenter", "DSP", "FiniteDifferences", "ImplicitDifferentiation", "Makie", "CairoMakie", "GenericSchur", "GR", "Plots", "SparseArrays", "StaticArrays"]
Loading
Loading