-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Docstring fix & small adjustements in demo_affine_image
#6673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
demo_affine_image
fig, ax1 = plt.subplots(1, 1) | ||
Z = get_image() | ||
im1 = ax1.imshow(Z, interpolation='none', | ||
origin='lower', | ||
extent=[-2, 4, -3, 2], clip_on=True) | ||
|
||
# image rotation | ||
trans_data2 = mtransforms.Affine2D().rotate_deg(30) + ax1.transData | ||
im1.set_transform(trans_data2) | ||
|
||
# display intended extent of the image | ||
x1, x2, y1, y2 = im1.get_extent() | ||
x3, y3 = x2, y1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these used for anything?
The offset between the image and rectangle does seem a bit odd... |
@QuLogic You're right, and I didn't pay attention enough: x3 and y3 weren't used anywhere. I also removed the import of I had an idea during the night and significantly modified the example to also show the image extent in the case where the affine transform is not applied. I've factorize the plotting of the extent rectangle and added some segment markers. However, the latters might be a bit overkill if one doesn't add a translation to the affine transorm (currently it's only a rotation). The commit 2f263b5 produces: @tacaswell I'll try to investigate the possible issue of the offset between the image and the rectangle (I guess I'll have to learn about the details of Affine2D first…). |
PR #6792 is not only about |
1/ Makes the red rectangle announced in the docstring red in the plot. The docstring has also been precised a bit.
2/ I think the comment about the image rotation was misplaced so I moved it where it seemed relevant to me.
3/ Finally, I've made the line width of the rectangle a bit bigger to be more visible and added a call to
plt.show()
The example should now looks like:

Remark 1: the colormap is not
viridis
because the colormap seems to default tognuplot2
in my conda env. I guess I had tweaked sthg and didn't remember it.Remark 2: the red rectangle does not seem to be perfectly centered on the image: the 2 upper sides are mostly over the image, while the 2 lower sides are mostly out of it. Is it expected?