r/learnpython • u/ProWizardKing • Sep 21 '24
Help with Matplotlib
I am creating a plot using Matplotlib and plotting lines on the image. I then want to zoom in on the image using slices while keeping the lines in the same position as the full scale image. How would you do so
Current code:
fig, ax = plt.subplots(1, 1, figsize=(16, 9))
plt.imshow(im17, vmin=np.min(im17), vmax=.0005*np.max(im17), origin="lower")
plt.colorbar()
x1, y1 = [cx_ne[i]-size_ne[i], cx_ne[i]+size_ne[i]+1], [cy_ne[i]-size_ne[i],cy_ne[i]-size_ne[i]+1]
x2, y2 = [cx_ne[i]-size_ne[i], cx_ne[i]+size_ne[i]+1], [cy_ne[i]+size_ne[i],cy_ne[i]+size_ne[i]+1]
x3, y3 = [cx_ne[i]-size_ne[i], cx_ne[i]-size_ne[i]+1], [cy_ne[i]-size_ne[i],cy_ne[i]+size_ne[i]+1]
x4, y4 = [cx_ne[i]+size_ne[i], cx_ne[i]+size_ne[i]+1], [cy_ne[i]-size_ne[i],cy_ne[i]+size_ne[i]+1]
plt.plot(x1, y1, x2, y2, x3, y3, x4, y4, color='red')
ax.set_title('HOPS 310')
View all comments
Show parent comment
1
u/ProWizardKing Sep 22 '24
https://imgur.com/a/dkPywqZ The big box is the slice I want and the little box is being retained in the same position