@@ -519,15 +519,17 @@ def gen_zero_centered_series(val_min, val_max, period):
519
519
520
520
# Default values for module parameter variables
521
521
_nyquist_defaults = {
522
- 'nyquist.primary_style' : ['-' , '-.' ], # style for primary curve
523
- 'nyquist.mirror_style' : ['--' , ':' ], # style for mirror curve
524
- 'nyquist.arrows' : 2 ,
525
- 'nyquist.arrow_size' : 8 ,
526
- 'nyquist.indent_radius' : 1e-6 , # indentation radius
522
+ 'nyquist.primary_style' : ['-' , '-.' ], # style for primary curve
523
+ 'nyquist.mirror_style' : ['--' , ':' ], # style for mirror curve
524
+ 'nyquist.arrows' : 2 , # number of arrors around curve
525
+ 'nyquist.arrow_size' : 8 , # pixel size for arrows
526
+ 'nyquist.indent_radius' : 1e-4 , # indentation radius
527
527
'nyquist.indent_direction' : 'right' , # indentation direction
528
528
'nyquist.indent_points' : 50 , # number of points to insert
529
- 'nyquist.max_curve_magnitude' : 20 ,
530
- 'nyquist.max_curve_offset' : 0.02 , # percent offset of curves
529
+ 'nyquist.max_curve_magnitude' : 20 , # clip large values
530
+ 'nyquist.max_curve_offset' : 0.02 , # offset of primary/mirror
531
+ 'nyquist.start_marker' : 'o' , # marker at start of curve
532
+ 'nyquist.start_marker_size' : 4 , # size of the maker
531
533
}
532
534
533
535
@@ -618,8 +620,9 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
618
620
are at or near the imaginary axis.
619
621
620
622
indent_radius : float, optional
621
- Amount to indent the Nyquist contour around poles that are at or near
622
- the imaginary axis.
623
+ Amount to indent the Nyquist contour around poles on or near the
624
+ imaginary axis. Portions of the Nyquist plot corresponding to indented
625
+ portions of the contour are plotted using a different line style.
623
626
624
627
max_curve_magnitude : float, optional
625
628
Restrict the maximum magnitude of the Nyquist plot to this value.
@@ -638,13 +641,22 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
638
641
`False` then omit completely. Default linestyle (['--', '-.']) is
639
642
determined by config.defaults['nyquist.mirror_style'].
640
643
641
- primary_style : [str, str]
644
+ primary_style : [str, str], optional
642
645
Linestyles for primary image of the Nyquist curve. The first element
643
646
is used for unscaled portions of the Nyquist curve, the second
644
647
element is used for scaled portions that are scaled (using
645
648
max_curve_magnitude). Default linestyle (['-', ':']) is determined by
646
649
config.defaults['nyquist.mirror_style'].
647
650
651
+ start_marker : str, optional
652
+ Matplotlib marker to use to mark the starting point of the Nyquist
653
+ plot. Defaults value is 'o' and can be set using
654
+ config.defaults['nyquist.start_marker'].
655
+
656
+ start_marker_size : float, optional
657
+ Start marker size (in display coordinates). Default value is
658
+ 4 and can be set using config.defaults['nyquist.start_marker_size'].
659
+
648
660
warn_nyquist : bool, optional
649
661
If set to 'False', turn off warnings about frequencies above Nyquist.
650
662
@@ -713,6 +725,10 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
713
725
'nyquist' , 'max_curve_magnitude' , kwargs , _nyquist_defaults , pop = True )
714
726
max_curve_offset = config ._get_param (
715
727
'nyquist' , 'max_curve_offset' , kwargs , _nyquist_defaults , pop = True )
728
+ start_marker = config ._get_param (
729
+ 'nyquist' , 'start_marker' , kwargs , _nyquist_defaults , pop = True )
730
+ start_marker_size = config ._get_param (
731
+ 'nyquist' , 'start_marker_size' , kwargs , _nyquist_defaults , pop = True )
716
732
717
733
# Set line styles for the curves
718
734
def _parse_linestyle (style_name , allow_false = False ):
@@ -848,6 +864,7 @@ def _parse_linestyle(style_name, allow_false=False):
848
864
start_freq , p .imag + indent_radius , indent_points )),
849
865
splane_contour [last_point :]))
850
866
867
+ # Indent points that are too close to a pole
851
868
for i , s in enumerate (splane_contour ):
852
869
# Find the nearest pole
853
870
p = splane_poles [(np .abs (splane_poles - s )).argmin ()]
@@ -929,13 +946,21 @@ def _parse_linestyle(style_name, allow_false=False):
929
946
'simple' , head_width = arrow_size , head_length = arrow_size )
930
947
931
948
# Find the different portions of the curve (with scaled pts marked)
932
- reg_mask = abs (resp ) > max_curve_magnitude
949
+ reg_mask = np .logical_or (
950
+ np .abs (resp ) > max_curve_magnitude ,
951
+ contour .real != 0 )
952
+ # reg_mask = np.logical_or(
953
+ # np.abs(resp.real) > max_curve_magnitude,
954
+ # np.abs(resp.imag) > max_curve_magnitude)
955
+
933
956
scale_mask = ~ reg_mask \
934
957
& np .concatenate ((~ reg_mask [1 :], ~ reg_mask [- 1 :])) \
935
958
& np .concatenate ((~ reg_mask [0 :1 ], ~ reg_mask [:- 1 ]))
936
959
937
960
# Rescale the points with large magnitude
938
- resp [reg_mask ] /= (np .abs (resp [reg_mask ]) / max_curve_magnitude )
961
+ rescale = np .logical_and (
962
+ reg_mask , abs (resp ) > max_curve_magnitude )
963
+ resp [rescale ] *= max_curve_magnitude / abs (resp [rescale ])
939
964
940
965
# Plot the regular portions of the curve (and grab the color)
941
966
x_reg = np .ma .masked_where (reg_mask , resp .real )
@@ -986,6 +1011,11 @@ def _parse_linestyle(style_name, allow_false=False):
986
1011
_add_arrows_to_line2D (
987
1012
ax , p [0 ], arrow_pos , arrowstyle = arrow_style , dir = - 1 )
988
1013
1014
+ # Mark the start of the curve
1015
+ if start_marker :
1016
+ plt .plot (resp [0 ].real , resp [0 ].imag , start_marker ,
1017
+ color = c , markersize = start_marker_size )
1018
+
989
1019
# Mark the -1 point
990
1020
plt .plot ([- 1 ], [0 ], 'r+' )
991
1021
0 commit comments