-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
imshow transparency blend example #9254
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
c6c5574
to
21b70a1
Compare
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.
I think this fails on 2.7.
I found the transparency effect to be pretty subtle, and wondered if an example could be created that had a different spatial pattern between the transparency and the underlying data.
I also found parts of the description and code could be described a bit more.
grid = np.array(np.meshgrid(xx, yy)) | ||
grid = grid.transpose(2, 1, 0) | ||
|
||
# Generate the blobs |
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.
Suggest specifying the expected data range of the raw blobs
# transparency with the image so that the extreme values are highlighted. | ||
# We'll also add in contour lines to highlight the image values. | ||
|
||
# Create an alpha channel based on weight values |
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.
Suggest specifying that this means data with an absolute value below 0.00004 will get an alpha of 0.4 and that above 0.0010 will get an alpha value of 1. I had to spend a couple of minutes figuring out what these two lines do.
map. In this case, it's common to visualize the statistic of choice (e.g., | ||
a t-statistic) alongisde another value of interest (e.g., the p-value for that | ||
statistic). One way to do this is to map the p-value onto the transparency of | ||
the image such that data with "significant" values are highlighted. |
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.
I found this description a bit mysterious. I'm not clear what is supposed to be "alongside" what. I thought at first you were referring to the x and y axes, but I don't think you are.
I'd simply say that its common to want to indicate significance of data values (or another quantity) using transparency overlain on an image.
took a stab at addressing comments...LMK what you think! |
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.
Looks nice!
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.
I like this a lot! Couple of things:
- Can the title cahnge to "Blend transparency with color in 2-D images"? (two 'with's in the same sentence doesn't quite sound right)
- CircleCI won't let me see why, but the 2.7 doc build is failing for some reason
The 2.7 fail is mysterious to me... The error message isn't helpful in circle and it builds fine on my 2.7 environment :-/ good idea on the title! Will change when I'm at my computer |
b4c581b
to
c46c9ef
Compare
latest push has the new name in it |
@QuLogic do you have any idea what this error could be on Circle 2.7? Not very informative and I can't recreate with 2.7 on my machine... |
Lets see if restarting the build does anything |
Maybe a sphinx-gallery issue, what version are you building with? CircleCI is sphinx-gallery=0.1.12 |
@choldgraf It looks like something in sphinx-gallery is trying to emit a warning, but doesn't pass the correct number of arguments, so it crashes. Unfortunately, sphinx hides everything but the final exception line, so it's very hard to say where the problem is right now. |
It's a bug in sphinx 1.6.4, caused by fixing a different messaging problem (reported by @anntzer sphinx-doc/sphinx#4070). Forcing installation of sphinx 1.6.3 should fix it. |
so that sounds like a change that should be made to the matplotlib sphinx build, not to this PR yeah? In that case nothing left to change here? |
I've added the change here because it's fairly small. |
hmmm, 2.7 still failing. I'll try to debug with sphinx-gallery on my machine |
I'm having a hard time getting the docs to build on my machine (just upgraded to a new computer and things are still wonky). Has anybody else been able to duplicate this sphinx bug? It doesn't seem related to this PR... |
It looks like some kind of scipy/numpy inconsistency. Maybe something wrong on conda-forge. |
so.....where are we on this one? 2.7 circle or appveyor aren't happy, though unclear if this is related to the PR. can we restart those builds? |
2.7 circleci is choking on |
It looks to me like there's a problem with scipy.stats finding some numpy methods. Perhaps the easiest fix would be replacing calls to z = np.exp(-(x**2 + y**2))
z = z / np.sum(z) |
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.
Can you replace scipy's multivariate_normal by numpy's? Scipy is not a requirements, and only has been added accidentally to our doc-requirements (without the actually documentation being updated).
Also, can you fix the random seed?
76e2166
to
4b7f4a5
Compare
e41171c
to
bf7567e
Compare
latest push removes |
bf7567e
to
750d4d8
Compare
tests are passing! |
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.
Thanks Chris!
Should this be backported so it's on the website before 2.2 is released? |
@meeseeksdev backport to v2.1.0-doc |
@tacaswell this meeseecks thing is amazing |
Backport PR #9254 on branch v2.1.0-doc
Per a recent conversation on twitter, this is an example that shows off how you can blend transparency in with imshow when you're using a 2-D data matrix (as opposed to an image). A person was asking about how to do this on twitter, and as it's a common visualization in neuroscience I think it'd be helpful for people if they had an idea for how to get it done. I looked into supporting this with imshow directly, but it is not a trivial thing to do, so I figured documentation is the next best step. LMK what folks think.