I created a zoomed portion (in box) of the plot with multiple curves, but the information inside the box is not showing
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes,mark_inset
fig= plt.figure(figsize=(15,10))
ax = plt.axes()
plt.plot(ADB[:300], color = 'darkorange')
plt.plot(ADB1[:300], color = 'green')
plt.plot(ADB2[:300], color = 'red')
plt.plot(ADB3[:300], color = 'darkblue')
plt.legend(fontsize=15)
plt.tick_params(labelsize=18)
axins = zoomed_inset_axes(ax,2,loc='upper right')
x1,x2,y1,y2 = 150,180, 300,400
axins.set_xlim(x1,x2)
axins.set_ylim(y1,y2)
mark_inset(ax,axins,loc1=2,loc2=1)
plt.show()
CodePudding user response:
You also need to plot your data on axins
. Take a look at the example provided by matplotlib.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes,mark_inset
fig= plt.figure(figsize=(15,10))
ax = plt.axes()
ax.plot(ADB[:300], color = 'darkorange')
ax.plot(ADB1[:300], color = 'green')
ax.plot(ADB2[:300], color = 'red')
ax.plot(ADB3[:300], color = 'darkblue')
ax.legend(fontsize=15)
ax.tick_params(labelsize=18)
axins = zoomed_inset_axes(ax,2,loc='upper right')
x1,x2,y1,y2 = 150,180, 300,400
axins.set_xlim(x1,x2)
axins.set_ylim(y1,y2)
axins.plot(ADB[:300], color = 'darkorange')
axins.plot(ADB1[:300], color = 'green')
axins.plot(ADB2[:300], color = 'red')
axins.plot(ADB3[:300], color = 'darkblue')
mark_inset(ax,axins,loc1=2,loc2=1)
plt.show()