Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Closed
wants to merge 2 commits into from

Conversation

afvincent
Copy link
Contributor

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:
modified_demo_affine_image

Remark 1: the colormap is not viridis because the colormap seems to default to gnuplot2 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?

@afvincent afvincent changed the title Docstring fix & small adjustements Docstring fix & small adjustements in demo_affine_image Jul 1, 2016
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
Copy link
Member

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?

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Jul 2, 2016
@tacaswell
Copy link
Member

The offset between the image and rectangle does seem a bit odd...

@afvincent
Copy link
Contributor Author

@QuLogic You're right, and I didn't pay attention enough: x3 and y3 weren't used anywhere. I also removed the import of matplotlib.cm that was also not used.

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:
modified_demo_affine_image_v1

@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…).

@afvincent
Copy link
Contributor Author

PR #6792 is not only about demo_affine_image but as it has replicated the docstring fixes and will provide an extended demo of the affine transformations that may be more relevant than my changes, I think it should supersede the current PR. So I'm going to close this one. Please reopen it if anyone thinks it was a mistake.

@afvincent afvincent closed this Jul 19, 2016
@QuLogic QuLogic modified the milestones: unassigned, 2.0.1 (next bug fix release) Aug 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants