Blank inset plot

26 Views Asked by At

I am trying to run this code but I am always getting blank zoomed plot. Is there any possible way in which it can be modified. Thanks in advance!! import matplotlib.ticker as ticker

fig, dx = plt.subplots(figsize=(10, 6), dpi=200)
plt.plot(test_pred, label = "Predicted", linestyle="-",color='blue')
plt.plot(test_y, label = "Reference", linestyle="-",color='red',)
plt.xlabel('Time(sec)')
plt.ylabel('V')
plt.legend()

# Add zoomed-in section of plot
zoom_start = 1600
zoom_end = 1700
zoom_size = 0.5
zoom_xrange = [zoom_start, zoom_end]
zoom_yrange = [min(test_y[zoom_start:zoom_end]) - zoom_size, max(test_y[zoom_start:zoom_end]) + zoom_size]

dxins = dx.inset_axes([0.3, 0.6, 0.4, 0.4])
dxins.set_xlim(zoom_xrange)
dxins.set_ylim(zoom_yrange)
dxins.plot(test_pred[zoom_start:zoom_end], linestyle="-",color='blue')
dxins.plot(test_y[zoom_start:zoom_end], linestyle="-",color='red',)
dx.indicate_inset_zoom(dxins)
plt.show()

I was trying to plot a zoomed in plot within a plot.

0

There are 0 best solutions below