最简单的方法是结合“zoomed_inset_axes”和“mark_inset”,其描述和相关示例可以在这里找到:Overview of AxesGrid toolkit import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes from mpl_to
axins=ax.inset_axes((0.5,0.6,0.2,0.3))#子图axins.plot()#子图绘画mark_inset(ax,axins,loc1=1,loc2=4,fc="none",ec='k',lw=1)#设置连线 代码 importnumpyasnpimportmatplotlib.pyplotaspltfrommpl_toolkits.axes_grid1.inset_locatorimportmark_insetfrommpl_toolkits.axes_grid1.inset_locatorimporti...
同一个模块中的另一个函数mark_inset()用于在父坐标系中绘制一个方框来表示主图中哪部分图形现在子图中,其完整语法如下, mark_inset(parent_axes, inset_axes, loc1, loc2, **kwargs) ( 1)参数parent_axes、inset_axes用来指定关联的父坐标系和子坐标系;( 2)参数loc1、loc2用来指定用于连接父坐标系区域...
1. 2. mark_inset意为插入图的标记 其中,parent_axes,inset_axes分别代表主图与子图的轴,loc1,loc2表示用于连接主图与子图轴区域的角,fc即facecolor,ec表示edgecolor,其他参数与线状参数类似。 函数参考:https://matplotlib.org/stable/api/_as_gen/mpl_toolkits.axes_grid1.inset_locator.mark_inset.html#m...
首先,我们需要导入Matplotlib库,并准备一些数据以绘制主图。然后,通过inset_axes方法创建一个小图(inset),并在其中绘制局部放大后的曲线。 import matplotlib.pyplot as plt import numpy as np 准备数据 x = np.linspace(0, 10, 100) y = np.sin(x) ...
axes = mark_inset(ax, axins, loc1=2, loc2=4, edgecolor='red', linestyle='dashed', linewidth=3) # 读取涡度变量 f = nc.Dataset('/home/mw/input/metos8969/metos/EI_VO_850hPa_Summer2001.nc', 'r') lats = f.variables['lat'][:] ...
set_ylim(ylim_ax2) # 设置Y轴显示范围 mark_inset(ax1, ax2, loc1=3, loc2=1, fc="none", ec='k', lw=1) # 放大区域与原位置的连接线 # 细节设置 ax1.set_xlabel('$t{\mathrm{(s)}}$') # 设置X轴标签 ax1.set_ylabel('$y$') # 设置Y轴标签 ax1.minorticks_off() # ax1.set...
plt.xticks(visible=True) plt.yticks(visible=True)#draw a bbox of the region of the inset axes in the parent axes and#connecting lines between the bbox and the inset axes areamark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5") ...
insetontime–指示灯闪烁的时间(以毫秒为单位)。 padx–水平填充。 pady–垂直填充。 state–定义窗口小部件是否将响应鼠标或键盘的移动。 highligththickness–定义焦点高光的厚度。 insertionwidth–定义插入字符的宽度。 relief–边框的类型, 可以是SUNKEN, RAISED, GROOVE和RIDGE。
frommpl_toolkits.axes_grid1.inset_locatorimportmark_inset frommatplotlib.patchesimportConnectionPatch %matplotlibinline plt.rcParams['figure.figsize']=(8.0,6.0)# set default size of plots plt.rcParams['image.interpolation']='nearest' plt.rcParams['image.cmap']='gray' ...