Improvements to Nichols chart plotting by roryyorke · Pull Request #723 · python-control/python-control
These are relatively minor updates to the Nichols chart (AKA grid) plotting.
It's far from ideal; further possible improvements:
- more tightly fitting the chart to the view (or data) xlim and ylim (the "extent"); the pain here is figuring out which contours to plot, and where to place the labels
- depending on the limits, some contours will end up with a two visible segments
- recreating the axis on zoom and pan events
- this might not be too difficult; Axes support
'xlim_changed'and'ylim_changed'events
- this might not be too difficult; Axes support
- a deluxe version of this would be too add (secondary?) axes, and show the closed-loop gain and phase in the "data value" text (the "x= , y = " on the Matplotlib toolbar)
- I wonder if we could use a custom
ContourSets, and plug into however that labelling is done?
Here are some before-and-after pictures (left is before) of a few example systems.
The new code gives a better result in almost all respects. One visible problem is that the closed-loop phase label for "0°" clashes with the "-40dB" (and similar) closed-loop gain label. The gains become crowded when the gain span is large (final figure), but that is the same in both versions.
I haven't added tests; I'll see how much time I have to do that. Easyish tests:
- check for "tight" phase limits (see first example below)
- check that the axes child text elements are have clip_on (I'd have to not check title & tick labels, presume this is possible)
- check for existence of phase labels, contingent on label_cl_phases flag
- test both branches of the
ifin_inner_extents, and in fact test the behaviour in general by setting xlim & ylim before calling nichols_grid.
Please suggest other tests.
Details (commit message)
Clip closed-loop contour labels.
Add labels for constant closed-loop phase contours.
Use smaller of data or view extents when deciding on how big, in
phase, a chart to create.
Use more uniformly spaced closed-loop phase contours, and use more
widely-spaced contours when phase extent is large.
Add optional ax argument, for axes to add grid to.



