8000 DOC: change colormap away from "jet" in examples by endolith · Pull Request #1327 · scikit-image/scikit-image · GitHub
[go: up one dir, main page]

Skip to content

DOC: change colormap away from "jet" in examples #1327

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

Merged
merged 2 commits into from
Feb 1, 2016

Conversation

endolith
Copy link
Contributor
  1. jet is generally discouraged as perceptually misleading: Replace "jet" as the default colormap matplotlib/matplotlib#875 (comment)
  2. I think it's more clear when all 3 images use the same colormap, to show how an edge detector converts a solid block of brightness into bright lines on just the edges:
          ______
    _____/      \_____  -->  _____/\____/\_____

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 47d2ee7 on endolith:patch-1 into f89ab05 on scikit-image:master.

@sciunto
Copy link
Member
sciunto commented Dec 28, 2014

The arguments seem to be convincing. How about the other examples:

doc/examples/applications/plot_coins_segmentation.py:117:ax.imshow(elevation_map, cmap=plt.cm.jet, interpolation='nearest')
doc/examples/applications/plot_rank_filters.py:527:fig.colorbar(ax2.imshow(entropy(image, disk(5)), cmap=plt.cm.jet), ax=ax2)
doc/examples/plot_canny.py:40:ax1.imshow(im, cmap=plt.cm.jet)
doc/examples/plot_edge_filter.py:73:ax3.imshow(edge_scharr - edge_sobel, cmap=plt.cm.jet)
doc/examples/plot_entropy.py:27:img1 = ax1.imshow(entropy(image, disk(5)), cmap=plt.cm.jet)
doc/examples/plot_watershed.py:56:ax1.imshow(-distance, cmap=plt.cm.jet, interpolation='nearest')
viewer_examples/plugins/watershed_demo.py:33:        viewer.ax.imshow(labels, cmap=plt.cm.jet, alpha=0.5)

@JDWarner
Copy link
Contributor

👍 I'm on board with never using cm.jet deliberately. It's bad for perception, and unintuitive for examples where people may incorrectly think we used an RGB image rather than mapping color on to a grayscale image.

@tacaswell
Copy link
Contributor

As a side note, changing the default color map (and forcing a v2.0) is on the near term horizon for mpl. The sticking point is not if it should be done, but what the new default should be.

@JDWarner
Copy link
Contributor

That is fantastic news, @tacaswell!

These still need fixed as they actually specify cm.jet.

@tacaswell
Copy link
Contributor

Yeah, I commented before I looked at the changes 🐑 .

@endolith
Copy link
Contributor Author

For the other examples, I'm not sure the best choice

http://scikit-image.org/docs/dev/auto_examples/applications/plot_coins_segmentation.html uses gray for the edge detector, then specifically switches to jet for the elevation map, and then spectral for the markers. Is there a reason for using jet? It looks like spectral was chosen because it conveniently colors a 3-value image with black, gray, and green? (Also this spectral has been renamed to nipy_spectral to distinguish it from the uppercase Spectral.)

Also we could use a different colormap than gray as long as it's one of the nicer ones that increases in brightness with height, like bone or YlGnBu_r.

@sciunto
Copy link
Member
sciunto commented Dec 29, 2014

IMO, gray would do the job instead of jet to show the 8000 effect of a sobel filter.

@blink1073
Copy link
Contributor

I like YlGnBu_r in the short term (for all previous uses of jet), followed by whatever the matplotlib folks settle on for their default. Too bad YlGnBu_r doesn't have a snazzier name. @tacaswell, you may want to consider giving your default map a name that is easy to remember (and say), like jet was.

@endolith
Copy link
Contributor Author
endolith commented Jan 2, 2015

I think viewer_examples/plugins/watershed_demo.py only works with jet? It's using it for labeled colors, not as a heatmap?

There's also \doc\examples\plot_phase_unwrap.py which I don't understand yet

@jni
Copy link
Member
jni commented Jan 2, 2015

@endolith I just noticed that! Jet is also inappropriate to show arbitrary label maps. Is there anything it can do? =P

For label maps, I think the best approach is a random colormap in Lab space, like I once did here

@endolith
Copy link
8000 Contributor Author
endolith commented Jan 2, 2015

Well I think that's what the qualitative colormaps are meant for? But they're currently implemented as LinearSegmentedColormap and should have been ListedColormap? matplotlib/matplotlib#881

@endolith
Copy link
Contributor Author
endolith commented Jan 2, 2015

Also I'm confused because it seems like skimage.feature and skimage.filters will be combined into skimage.filter, but the documentation follows this and the actual code doesn't yet? http://stackoverflow.com/a/26877466/125507 Like watershed_demo has from skimage import filters and then edge_image = filter.sobel(viewer.image)?

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 3a49af5 on endolith:patch-1 into f89ab05 on scikit-image:master.

@jni
Copy link
Member
jni commented Jan 2, 2015

@endolith no, the two modules aren't merging. Canny was moved from filter to feature, and filter will be renamed filters. filter.sobel is a bug, missed in the rename. Can you point me to the exact line in the codebase?

Regarding colormaps, I don't have all that much experience in this space... Is there a qualitative map that can be used for an arbitrary number of segments?

@blink1073
Copy link
Contributor

@endolith, I think we need @tonysyu to weigh in on whether to change to a ListedColormap, since he implemented the LinearColormap.

@tonysyu
Copy link
Member
tonysyu commented Jan 3, 2015

I think it's a good idea to define some ListedColormaps for this purpose. The LinearColormap is a nice easy way to get color palettes from certain colormaps (e.g. the cm.Set* colormaps), but now that you mention it, a better alternative would be to sample the colormap and save it as a real qualitative colormap; e.g.:

qcmap_jet = ListedColormap(plt.cm.jet(np.linspace(0, 1, 5)))

@stefanv
Copy link
Member
stefanv commented Jul 7, 2015

I guess we need to wait for matplotlib to finalize their decision, but at least we have alternatives now at http://bids.github.io/colormap/

@blink1073
Copy link
Contributor

I think should include the viridia look up table in utils and perhaps set it upon import of skimage if jet is the current setting.

@stefanv
Copy link
Member
stefanv commented Jul 11, 2015

I would not override the matplotlib defaults, in case the user chose to use something different. But we can make sure that, when io.imshow is called and the matplotlib backend is in place, viridis is used. Perhaps viridis can be exposed even more prominently so that users can use it easily?

@blink1073
Copy link
Contributor

skimage.set_cmap?


Sent from Mailbox

On Sat, Jul 11, 2015 at 1:08 PM, Stefan van der Walt
notifications@github.com wrote:

I would not override the matplotlib defaults, in case the user chose to use something different. But we can make sure that, when io.imshow is called and the matplotlib backend is in place, viridis is used. Perhaps viridis can be exposed even more prominently so that users can use it easily?

Reply to this email directly or view it on GitHub:
#1327 (comment)

@stefanv
Copy link
Member
stefanv commented Jul 11, 2015

I shy away from carrying state. It often leaves an awful mess in notebooks, e.g.

@blink1073
Copy link
Contributor

How about if we register the cmap on import, and then use it by string literal name by default in imshow and all of our examples?

@stefanv
Copy link
Member
stefanv commented Jul 12, 2015 via email

@endolith endolith changed the title DOC: change colormap to gray DOC: change colormap away from jet in examples Jul 14, 2015
@endolith endolith changed the title DOC: change colormap away from jet in examples DOC: change colormap away from "jet" in examples Jul 14, 2015
@endolith
Copy link
Contributor Author
  1. This PR is just for changing the examples, not the whole package's default.
  2. Yes, some of these should be using ListedColormap instead of LinearSegmentedColormap, but BUG: Convert qualitative colormaps to ListedColormap matplotlib/matplotlib#3973 isn't changing for a while, so there isn't a convenient way to do this in examples yet. Is this patch acceptable as is for now?

@blink1073
Copy link
Contributor

@endolith, this is also about a consistent message throughout the library. We'd like to present a clear alternative to jet that has superior visual perception properties.

@blink1073
Copy link
Contributor

@endolith, it looks like nipy_spectral was added in a later version of matplotlib, which is why the Python 2.7 build is failing.

@blink1073
Copy link
Contributor

Perhaps just use cubehelix instead of nipy_spectral and we'll call it a day on this one?

@endolith
Copy link
Contributor Author

Oh. nipy_spectral is a synonym for spectral that I made to distinguish it from Spectral. In the future it should be used, but if it's making the tests fail I can just change it back.

@endolith
Copy link
Contributor Author

Ok, rebased and removed nipy_spectral for now

@stefanv
Copy link
Member
stefanv commented Jul 17, 2015

Some of these should probably use the new colormap proposed in #1599

@soupault soupault added 🔧 type: Maintenance Refactoring and maintenance of internals ⏩ type: Enhancement Improve existing features labels Jan 30, 2016
@soupault
Copy link
Member

/ping @endolith
Hi! Could you, please, rebase once again? We should really finalize this.

@endolith
Copy link
Contributor Author

ok, rebased

@@ -54,7 +54,7 @@

ax0.imshow(image, cmap=plt.cm.gray, interpolation='nearest')
ax0.set_title('Overlapping objects')
ax1.imshow(-distance, cmap=plt.cm.jet, interpolation='nearest')
ax1.imshow(-distance, cmap=plt.cm.gray, interpolation='nearest')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to use non-grayscale colormap here, as it better presents what is actually the result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

figure_1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, gray is probably one of the best options here.
I wanted to get terrain-like effect, but to get one the image with higher resolution and histogram equalization are required.

@soupault
Copy link
Member
soupault commented Feb 1, 2016

Thanks @endolith ! One minor comment from my side and we're ready to go.

@soupault
Copy link
Member
soupault commented Feb 1, 2016

👍

@jni
Copy link
Member
jni commented Feb 1, 2016

Merging this, thank you @endolith!

@scikit-image/core if we want to make some examples use viridis, we can use a different PR for that.

jni added a commit that referenced this pull request Feb 1, 2016
DOC: change colormap away from "jet" in examples
@jni jni merged commit 4eee2ee into scikit-image:master Feb 1, 2016
@endolith endolith deleted the patch-1 branch February 1, 2016 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏩ type: Enhancement Improve existing features 🔧 type: Maintenance Refactoring and maintenance of internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants
0