Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Interactive Root Locus GUI with High-Resolution Catmull-Rom Interpolation#1175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
AndrewTrepagnier wants to merge6 commits intopython-control:main
base:main
Choose a base branch
Loading
fromAndrewTrepagnier:main
Open
Show file tree
Hide file tree
Changes fromall 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
8 changes: 8 additions & 0 deletionscontrol/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
specialized functionality:

* :mod:`~control.flatsys`: Differentially flat systems
* :mod:`~control.interactive`: Interactive plotting tools
* :mod:`~control.matlab`: MATLAB compatibility module
* :mod:`~control.optimal`: Optimization-based control
* :mod:`~control.phaseplot`: 2D phase plane diagrams
Expand DownExpand Up@@ -87,6 +88,13 @@
from .passivity import *
from .sysnorm import *

# Interactive plotting tools
try:
from .interactive import *
except ImportError:
# Interactive tools may not be available if plotly is not installed
pass

# Allow access to phase_plane functions as ct.phaseplot.fcn or ct.pp.fcn
from . import phaseplot as phaseplot
pp = phaseplot
Expand Down
99 changes: 99 additions & 0 deletionscontrol/interactive/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
# Interactive Plotting Tools

This module provides interactive plotting capabilities for the Python Control Systems Library.

## Root Locus GUI

The `root_locus_gui` function creates an interactive root locus plot with hover functionality.

### Features

- **Hover Information**: Hover over the root locus to see gain, damping ratio, and frequency
- **Original Plot Style**: Uses the same visual style as the original matplotlib root locus plots
- **Interactive Info Box**: Small info box in the corner shows real-time information
- **Cursor Marker**: Green dot follows your mouse to show exactly where you are on the root locus
- **Poles and Zeros**: Visual display of open-loop poles and zeros
- **Customizable**: Various options for display and interaction

### Basic Usage

```python
import control as ct

# Create a system
s = ct.tf('s')
sys = 1 / (s**2 + 2*s + 1)

# Create interactive root locus plot
gui = ct.root_locus_gui(sys)
gui.show()
```

### Advanced Usage

```python
# Customize the plot
gui = ct.root_locus_gui(
sys,
title="My Root Locus",
show_grid_lines=True,
damping_lines=True,
frequency_lines=True
)
gui.show()
```

### Parameters

- `sys`: LTI system (SISO only)
- `gains`: Custom gain range (optional)
- `xlim`, `ylim`: Axis limits (optional)
- `grid`: Show s-plane grid (default: True)
- `show_poles_zeros`: Show poles and zeros (default: True)
- `show_grid_lines`: Show grid lines (default: True)
- `damping_lines`: Show damping ratio lines (default: True)
- `frequency_lines`: Show frequency lines (default: True)
- `title`: Plot title

### Hover Information

When you hover over the root locus, you can see:

- **Gain**: The current gain value
- **Pole**: The pole location in the s-plane
- **Damping**: Damping ratio (for complex poles)
- **Frequency**: Natural frequency (for complex poles)

A green dot marker will appear on the root locus curve to show exactly where your cursor is positioned.

### Installation

The interactive tools require matplotlib:

```bash
pip install matplotlib
```

### Examples

See the `examples/` directory for more detailed examples:

- `simple_rlocus_gui_example.py`: Basic usage

### Comparison with MATLAB

This GUI provides similar functionality to MATLAB's root locus tool:

| Feature | MATLAB | Python Control |
|---------|--------|----------------|
| Hover information | ✓ | ✓ |
| Grid lines | ✓ | ✓ |
| Poles/zeros display | ✓ | ✓ |
| Custom gain ranges | ✓ | ✓ |
| Desktop application | ✓ | ✓ |
| Jupyter integration | ✗ | ✓ |
| Cursor marker | ✗ | ✓ |

### Comparison with Existing Functionality

The python-control library already has some interactive features:
30 changes: 30 additions & 0 deletionscontrol/interactive/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
"""
Interactive plotting tools for the Python Control Systems Library.

This module provides interactive plotting capabilities including root locus
analysis with hover functionality.
"""

try:
from .rlocus_gui import root_locus_gui, rlocus_gui, root_locus_gui_advanced
__all__ = ['root_locus_gui', 'rlocus_gui', 'root_locus_gui_advanced']
except ImportError as e:
def root_locus_gui(*args, **kwargs):
raise ImportError(
f"root_locus_gui could not be imported: {e}. "
"Make sure matplotlib is installed: pip install matplotlib"
)

def rlocus_gui(*args, **kwargs):
raise ImportError(
f"rlocus_gui could not be imported: {e}. "
"Make sure matplotlib is installed: pip install matplotlib"
)

def root_locus_gui_advanced(*args, **kwargs):
raise ImportError(
f"root_locus_gui_advanced could not be imported: {e}. "
"Make sure matplotlib is installed: pip install matplotlib"
)

__all__ = ['root_locus_gui', 'rlocus_gui', 'root_locus_gui_advanced']
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp