@@ -477,6 +477,22 @@ def addmpl(self, tab='guide', pow_index=0):
477477 if pow_index < 0 :
478478 pow_index_guide -= 1 # Display the -2 guide for the -1 beam
479479
480+ x_min = self .x [0 ]
481+ x_max = self .x [- 1 ]
482+
483+ if (self .topology == 'array' # If array of guides
484+ and self .nbr_p != 0 and self .p != 0 # If guides exists
485+ and self .peaks [0 , 0 ] >= self .x [0 ] # If guides in the windows
486+ and self .peaks [- 1 , - 1 ] <= self .x [- 1 ]):
487+ x_min = self .offset_guide - self .nbr_p * self .p
488+ x_max = self .offset_guide + self .nbr_p * self .p
489+
490+ if (self .topology == 'curved' # If curved guides
491+ and self .peaks [0 , 0 ] >= self .x [0 ] # If guides in the windows
492+ and self .peaks [- 1 , - 1 ] <= self .x [- 1 ]):
493+ x_min = self .peaks [0 , 0 ] - self .width
494+ x_max = self .peaks [- 1 , - 1 ] + self .width
495+
480496 if tab == 'guide' :
481497 fig = Figure ()
482498 fig .set_tight_layout (True ) # Prevent axes to be cut when resizing
@@ -485,16 +501,7 @@ def addmpl(self, tab='guide', pow_index=0):
485501 ax1 .set_xlabel ('x (µm)' )
486502 ax1 .set_ylabel ('z (mm)' )
487503
488- if self .nbr_p != 0 and self .p != 0 and self .topology != 'curved' :
489- x_min = self .offset_guide - self .nbr_p * self .p
490- if x_min < self .x [0 ]:
491- x_min = self .x [0 ]
492-
493- x_max = self .offset_guide + self .nbr_p * self .p
494- if x_max > self .x [- 1 ]:
495- x_max = self .x [- 1 ]
496-
497- ax1 .set_xlim (x_min , x_max )
504+ ax1 .set_xlim (x_min , x_max )
498505
499506 # note that a colormesh pixel is based on 4 points
500507 ax1 .pcolormesh (self .xv ,
@@ -524,16 +531,7 @@ def addmpl(self, tab='guide', pow_index=0):
524531 poly = Polygon (verts , facecolor = '0.9' , edgecolor = '0.5' )
525532 ax2 .add_patch (poly )
526533
527- if self .p != 0 and self .topology != 'curved' :
528- x_min = self .offset_guide - self .nbr_p * self .p
529- if x_min < self .x [0 ]:
530- x_min = self .x [0 ]
531-
532- x_max = self .offset_guide + self .nbr_p * self .p
533- if x_max > self .x [- 1 ]:
534- x_max = self .x [- 1 ]
535-
536- ax2 .set_xlim (x_min , x_max )
534+ ax2 .set_xlim (x_min , x_max )
537535
538536 ax2 .set_ylim (0 ,
539537 max (self .dn [0 , :])* 1.1 + 1E-20 )
@@ -572,16 +570,7 @@ def addmpl(self, tab='guide', pow_index=0):
572570 poly = Polygon (verts , facecolor = '0.9' , edgecolor = '0.5' )
573571 ax1 .add_patch (poly )
574572
575- if self .p != 0 and self .topology != 'curved' :
576- x_min = self .offset_guide - self .nbr_p * self .p
577- if x_min < self .x [0 ]:
578- x_min = self .x [0 ]
579-
580- x_max = self .offset_guide + self .nbr_p * self .p
581- if x_max > self .x [- 1 ]:
582- x_max = self .x [- 1 ]
583-
584- ax1 .set_xlim (x_min , x_max )
573+ ax1 .set_xlim (x_min , x_max )
585574
586575 ax1 .set_ylim (0 ,
587576 max (1.1 * self .dn [pow_index_guide , :]) + 1E-20 )
@@ -621,18 +610,7 @@ def addmpl(self, tab='guide', pow_index=0):
621610 ax1 .set_xlabel ('x (µm)' )
622611 ax1 .set_ylabel ('z (mm)' )
623612
624- if (self .nbr_p != 0 and self .p != 0
625- and self .topology != 'curved' ):
626-
627- x_min = self .offset_guide - self .nbr_p * self .p
628- if x_min < self .x [0 ]:
629- x_min = self .x [0 ]
630-
631- x_max = self .offset_guide + self .nbr_p * self .p
632- if x_max > self .x [- 1 ]:
633- x_max = self .x [- 1 ]
634-
635- ax1 .set_xlim (x_min , x_max )
613+ ax2 .set_xlim (x_min , x_max )
636614
637615 ax1 .pcolormesh (self .xv ,
638616 self .zv ,
0 commit comments