Saturday, November 22, 2025
HomeLanguagesMatplotlib.axes.Axes.indicate_inset_zoom() in Python

Matplotlib.axes.Axes.indicate_inset_zoom() in Python

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.

matplotlib.axes.Axes.indicate_inset_zoom() Function

The Axes.indicate_inset() function in axes module of matplotlib library is also used to add an inset indicator to the axes.

Syntax: Axes.indicate_inset(self, bounds, inset_ax=None, *, transform=None, facecolor=’none’, edgecolor=’0.5′, alpha=0.5, zorder=4.99, **kwargs) 

Parameters: This method accept the following parameters that are described below:

  • inset_ax: This parameter is an optional inset axes to draw connecting lines to.
  • **kwargs: Other kwargs are passed on to Axes.inset_rectangle.

Returns: This method returns the following:

  • rectangle_patch : This return the indicator frame.
  • connector_lines: This return the four connector lines connecting to (lower_left, upper_left, lower_right upper_right) corners of inset_ax.

Note: This function works in Matplotlib version >= 3.0 

Below examples illustrate the matplotlib.axes.Axes.indicate_inset_zoom() function in matplotlib.axes: 

Example 1: 

Python3




# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
 
 
Z2 = np.zeros([150, 150], dtype ="g")
 
axins = ax.inset_axes([0.5, 0.5, 0.47, 0.47])
x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
axins.set_xlim(x1, x2)
axins.set_ylim(y1, y2)
  
ax.indicate_inset_zoom(axins)
 
ax.set_title('matplotlib.axes.Axes.indicate_inset_zoom() Example',
             fontsize = 14, fontweight ='bold')
plt.show()


Output:

  

Example 2: 

Python3




# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
  
  
def neveropen():
    from matplotlib.cbook import get_sample_data
    import numpy as np
    f = get_sample_data("axes_grid / bivariate_normal.npy",
                        asfileobj = False)
    z = np.load(f)
    return z, (-3, 4, -4, 3)
  
fig, ax = plt.subplots()
  
X, extent = neveropen()
Z2 = np.zeros([150, 150], dtype ="g")
ny, nx = X.shape
Z2[30:30 + ny, 30:30 + nx] = X
  
ax.imshow(Z2, extent = extent, interpolation ="nearest",
          origin ="lower", cmap ="YlGn")
  
axins = ax.inset_axes([0.5, 0.5, 0.47, 0.47])
axins.imshow(Z2, extent = extent, interpolation ="nearest",
          origin ="lower", cmap ="BuGn")
x1, x2, y1, y2 = -1.5, -0.9, -2.5, -1.9
axins.set_xlim(x1, x2)
axins.set_ylim(y1, y2)
  
ax.indicate_inset_zoom(axins)
  
ax.set_title('matplotlib.axes.Axes.indicate_inset_zoom() Example',
             fontsize = 14, fontweight ='bold')
plt.show()


Output:

 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6784 POSTS0 COMMENTS
Nicole Veronica
11931 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11999 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6863 POSTS0 COMMENTS
Umr Jansen
6848 POSTS0 COMMENTS