Repository navigation
too much white space around Root Locus with omega-damping grid #1147
Description
Activity
I cannot reproduce on the current tip of
mainbranch, so this must have been fixed already. There is a new release coming soon: #1130@slivingston Did you run inside a Jupyter notebook? What version?
I tried running this using the following versions and got the same problem as @datacurse noted:
IPython : 8.31.0 ipykernel : 6.29.5 ipywidgets : 8.1.5 jupyter_client : 8.6.3 jupyter_core : 5.7.2 jupyter_server : 2.14.2 jupyterlab : 4.3.3 nbclient : 0.10.1 nbconvert : 7.16.4 nbformat : 5.10.4 notebook : 7.3.1 qtconsole : not installed traitlets : 5.14.3I also tried running this on Colab and I get the same problem using the following commands:
!pip install git+https://github.com/python-control/python-control.git import control as ct import matplotlib.pyplot as plt sys = ct.tf([1, 2], [1, 0, 0]) cplt = ct.root_locus(sys, grid=True)No, I ran it in IPython in a terminal, so the Matplotlib backend would be different. I just tried in Colab and reproduced it (like you), so now I think it is something new.
With matplotlib 3.10.0, I can reproduce this. (Also happens in Colab, at time of writing, and Colab is also running matplotlib 3.10.0)
With matplotlib 3.11.0, there's no extra whitespace, but the damping grid lines look wrong.
Other installed packages at end; apologies for long list, I also installed jupyterlab.
matplotlib 3.10.0
matplotlib 3.11.0
packages
changing matplotlib versions didn't result in any upgrade or downgrade of other packages. This list is for matplotlib 3.11.0.
Package Version Editable project location ------------------------- ----------------------- ------------------------------ anyio 4.14.1 argon2-cffi 25.1.0 argon2-cffi-bindings 25.1.0 arrow 1.4.0 asttokens 3.0.1 async-lru 2.3.0 attrs 26.1.0 babel 2.18.0 beautifulsoup4 4.15.0 bleach 6.4.0 certifi 2026.6.17 cffi 2.1.0 charset-normalizer 3.4.9 comm 0.2.3 contourpy 1.3.3 control 0.10.3.dev20+g7d5019e0b /home/roryy/src/python-control cycler 0.12.1 debugpy 1.8.21 decorator 5.3.1 defusedxml 0.7.1 executing 2.2.1 fastjsonschema 2.21.2 fonttools 4.63.0 fqdn 1.5.1 h11 0.16.0 httpcore 1.0.9 httpx 0.28.1 idna 3.18 ipykernel 7.3.0 ipython 9.15.0 ipython_pygments_lexers 1.1.1 isoduration 20.11.0 jedi 0.20.0 Jinja2 3.1.6 json5 0.15.0 jsonpointer 3.1.1 jsonschema 4.26.0 jsonschema-specifications 2025.9.1 jupyter_builder 1.1.0 jupyter_client 8.9.1 jupyter_core 5.9.1 jupyter-events 0.12.1 jupyter-lsp 2.3.1 jupyter_server 2.20.0 jupyter_server_terminals 0.5.4 jupyterlab 4.6.1 jupyterlab_pygments 0.3.0 jupyterlab_server 2.28.0 kiwisolver 1.5.0 lark 1.3.1 MarkupSafe 3.0.3 matplotlib 3.11.0 matplotlib-inline 0.2.2 mistune 3.3.3 nbclient 0.11.0 nbconvert 7.17.1 nbformat 5.10.4 nest-asyncio2 1.7.2 notebook 7.6.0 notebook_shim 0.2.4 numpy 2.5.1 packaging 26.2 pandocfilters 1.5.1 parso 0.8.7 pexpect 4.9.0 pillow 12.3.0 pip 25.1.1 platformdirs 4.10.0 prometheus_client 0.25.0 prompt_toolkit 3.0.52 psutil 7.2.2 ptyprocess 0.7.0 pure_eval 0.2.3 pycparser 3.0 Pygments 2.20.0 pyparsing 3.3.2 python-dateutil 2.9.0.post0 python-json-logger 4.1.0 PyYAML 6.0.3 pyzmq 27.1.0 referencing 0.37.0 requests 2.34.2 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 rfc3987-syntax 1.1.0 rpds-py 2026.6.3 scipy 1.18.0 Send2Trash 2.1.0 six 1.17.0 soupsieve 2.8.4 stack-data 0.6.3 terminado 0.18.1 tinycss2 1.5.1 tornado 6.5.7 traitlets 5.15.1 typing_extensions 4.16.0 tzdata 2026.3 uri-template 1.3.0 urllib3 2.7.0 wcwidth 0.8.2 webcolors 25.10.0 webencodings 0.5.1 websocket-client 1.9.0control's
grid.pydefinesModifiedExtremeCycleFinder, subclassing matplotlib'sangle_helper.ExtremeFinderCycle, and overrides__call__.ExtremeFinderCycleis a subclass ofExtremeFinderSimple.Somewhere between matplotlib 3.10.0 and 3.11.0, matplotlib moved the extreme finder logic into
_find_transformed_bbox, which is called byExtremeFinderSimple's__call__, and_find_transformed_bboxis directly called in some places, e.g., GridFinder.get_grid_info. In control,_find_transformed_bboxis not overridden, so we're getting the "finder" behaviour ofExtremeFinderCycle.See https://gist.github.com/roryyorke/655741c97b6bb6062f6fcb037151cac1/revisions for diff of
grid_finder.pybetween 3.10.0 and 3.11.0 (this is "by-hand" created in Github gist; Github doesn't have easily accessible file-diff-between-version capability).I did a cursory search of matplotlib's issues for ExtremeFinderSimple and _find_transformed_bbox, but nothing is mentioned. The docs for this corner of matplotlib are a bit thin.
Anyway, the fix on the control side is to move the calcs in
ModifiedExtremeCycleFinder.__call__to_find_transformed_bbox, and (to be confirmed) just omit the__call__override.That doesn't solve the extra whitespace question for Matplotlib 3.10.0, of course - I've hijacked the discussion around that a bit, sorry.
When I turn on the omega-damping grid for root locus plot with
grid=True(turned on by default), it adds too much white space around the actual plot, which is very annoying. With this grid turned off, plot is tight and nice.I would like root locus to not have this extra white space around when grid is turned on, I am pretty sure this is some sort of platform-specific bug. Would appreciate any help 🙏
grid turned on (probably bug):

grid turned off (expected behavior):

Libraries:
I'm using python control in Google Colab.