From da64b63f5a2ed66474c40a74bccf77eaed9089b9 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Fri, 15 May 2026 19:34:08 +0200 Subject: [PATCH] Fix marginplot variable assignment when filtering phase margins The block that limits the displayed phase margins to the 5 smallest mistakenly assigned to `wgm`/`gm` (the gain-margin display variables) instead of `wpm`/`pm`, overwriting the gain-margin data with phase-margin data whenever `length(pm) > 5`. Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/ControlSystemsBase/src/plotting.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ControlSystemsBase/src/plotting.jl b/lib/ControlSystemsBase/src/plotting.jl index 4f5b38ad0..f69872b34 100644 --- a/lib/ControlSystemsBase/src/plotting.jl +++ b/lib/ControlSystemsBase/src/plotting.jl @@ -810,8 +810,8 @@ marginplot if length(pm) > 5 @warn "Only showing \"smallest\" 5 out of $(length(pm)) phase margins" idx = sortperm(pm) - wgm = wpm[idx[1:5]] - gm = pm[idx[1:5]] + wpm = wpm[idx[1:5]] + pm = pm[idx[1:5]] end if _PlotScale == "dB" mag = 20 .* log10.(1 ./ gm)