@@ -278,10 +278,16 @@ def get_path(self):
278
278
return Path (path_merged )
279
279
280
280
281
- def _add_inset_axes (parent_axes , inset_axes ):
281
+ def _add_inset_axes (parent_axes , axes_class , axes_kwargs , axes_locator ):
282
282
"""Helper function to add an inset axes and disable navigation in it."""
283
- parent_axes .figure .add_axes (inset_axes )
284
- inset_axes .set_navigate (False )
283
+ if axes_class is None :
284
+ axes_class = HostAxes
285
+ if axes_kwargs is None :
286
+ axes_kwargs = {}
287
+ inset_axes = axes_class (
288
+ parent_axes .figure , parent_axes .get_position (),
289
+ ** {"navigate" : False , ** axes_kwargs , "axes_locator" : axes_locator })
290
+ return parent_axes .figure .add_axes (inset_axes )
285
291
286
292
287
293
@_docstring .dedent_interpd
@@ -386,42 +392,25 @@ def inset_axes(parent_axes, width, height, loc='upper right',
386
392
Inset axes object created.
387
393
"""
388
394
389
- if axes_class is None :
390
- axes_class = HostAxes
391
- if axes_kwargs is None :
392
- axes_kwargs = {}
393
- inset_axes = axes_class (parent_axes .figure , parent_axes .get_position (),
394
- ** axes_kwargs )
395
-
396
- if bbox_transform in [parent_axes .transAxes ,
397
- parent_axes .figure .transFigure ]:
398
- if bbox_to_anchor is None :
399
- _api .warn_external ("Using the axes or figure transform requires a "
400
- "bounding box in the respective coordinates. "
401
- "Using bbox_to_anchor=(0, 0, 1, 1) now." )
402
- bbox_to_anchor = (0 , 0 , 1 , 1 )
403
-
395
+ if (bbox_transform in [parent_axes .transAxes , parent_axes .figure .transFigure ]
396
+ and bbox_to_anchor is None ):
397
+ _api .warn_external ("Using the axes or figure transform requires a "
398
+ "bounding box in the respective coordinates. "
399
+ "Using bbox_to_anchor=(0, 0, 1, 1) now." )
400
+ bbox_to_anchor = (0 , 0 , 1 , 1 )
404
401
if bbox_to_anchor is None :
405
402
bbox_to_anchor = parent_axes .bbox
406
-
407
403
if (isinstance (bbox_to_anchor , tuple ) and
408
404
(isinstance (width , str ) or isinstance (height , str ))):
409
405
if len (bbox_to_anchor ) != 4 :
410
406
raise ValueError ("Using relative units for width or height "
411
407
"requires to provide a 4-tuple or a "
412
408
"`Bbox` instance to `bbox_to_anchor." )
413
-
414
- axes_locator = AnchoredSizeLocator (bbox_to_anchor ,
415
- width , height ,
416
- loc = loc ,
417
- bbox_transform = bbox_transform ,
418
- borderpad = borderpad )
419
-
420
- inset_axes .set_axes_locator (axes_locator )
421
-
422
- _add_inset_axes (parent_axes , inset_axes )
423
-
424
- return inset_axes
409
+ return _add_inset_axes (
410
+ parent_axes , axes_class , axes_kwargs ,
411
+ AnchoredSizeLocator (
412
+ bbox_to_anchor , width , height , loc = loc ,
413
+ bbox_transform = bbox_transform , borderpad = borderpad ))
425
414
426
415
427
416
@_docstring .dedent_interpd
@@ -493,22 +482,12 @@ def zoomed_inset_axes(parent_axes, zoom, loc='upper right',
493
482
Inset axes object created.
494
483
"""
495
484
496
- if axes_class is None :
497
- axes_class = HostAxes
498
- if axes_kwargs is None :
499
- axes_kwargs = {}
500
- inset_axes = axes_class (parent_axes .figure , parent_axes .get_position (),
501
- ** axes_kwargs )
502
-
503
- axes_locator = AnchoredZoomLocator (parent_axes , zoom = zoom , loc = loc ,
504
- bbox_to_anchor = bbox_to_anchor ,
505
- bbox_transform = bbox_transform ,
506
- borderpad = borderpad )
507
- inset_axes .set_axes_locator (axes_locator )
508
-
509
- _add_inset_axes (parent_axes , inset_axes )
510
-
511
- return inset_axes
485
+ return _add_inset_axes (
486
+ parent_axes , axes_class , axes_kwargs ,
487
+ AnchoredZoomLocator (
488
+ parent_axes , zoom = zoom , loc = loc ,
489
+ bbox_to_anchor = bbox_to_anchor , bbox_transform = bbox_transform ,
490
+ borderpad = borderpad ))
512
491
513
492
514
493
class _TransformedBboxWithCallback (TransformedBbox ):
@@ -565,11 +544,8 @@ def mark_inset(parent_axes, inset_axes, loc1, loc2, **kwargs):
565
544
inset_axes .viewLim , parent_axes .transData ,
566
545
callback = parent_axes ._unstale_viewLim )
567
546
568
- if 'fill' in kwargs :
569
- pp = BboxPatch (rect , ** kwargs )
570
- else :
571
- fill = bool ({'fc' , 'facecolor' , 'color' }.intersection (kwargs ))
572
- pp = BboxPatch (rect , fill = fill , ** kwargs )
547
+ kwargs .setdefault ("fill" , bool ({'fc' , 'facecolor' , 'color' }.intersection (kwargs )))
548
+ pp = BboxPatch (rect , ** kwargs )
573
549
parent_axes .add_patch (pp )
574
550
575
551
p1 = BboxConnector (inset_axes .bbox , rect , loc1 = loc1 , ** kwargs )
0 commit comments