-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
DOC: colormap-manipulation tutorial #11905
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
DOC: colormap-manipulation tutorial #11905
Conversation
This is ready for suggestion (but not formal review, as I've not linked everything, nor squashed all flake8 complaints) |
a0582fc
to
2d51a38
Compare
2d51a38
to
f58f5f3
Compare
Removing work in progress, though one could argue that some of this should end up in |
# 0.5 of the colormap. | ||
|
||
viridis = cm.get_cmap('viridis', 256) | ||
newcmp = ListedColormap(viridis(np.linspace(0.25, 0.75, 256))) |
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.
Will this have over-sampling issues?
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.
Ooops, yes it will. Not really noticeable at 256 resolution, but would certainly be a problem for small colormaps. Changed to
# We can easily reduce the dynamic range of a colormap; here we choose the middle
# 0.5 of the colormap. However, we need to interpolate from a larger
# colormap, otherwise the new colormap will have repeated values.
viridisBig = cm.get_cmap('viridis', 512)
newcmp = ListedColormap(viridisBig(np.linspace(0.25, 0.75, 256)))
plot_examples([viridis, newcmp])
Overall I like this! I might tone down selling how hard this is in the top of the tutorial a bit. |
Fair enough - I shouldn't point out my own confusion in tutorials. First two paragraphs now just one:
|
I added a one word commit (removed 'quite' as I think it falls into the same category as 'just' as a word that can be read by people who don't already know the next part of the sentence as "only dumb people do not know ..." ). |
lib/matplotlib/cm.py
Outdated
@@ -1,8 +1,13 @@ | |||
""" | |||
Builtin colormaps, colormap handling utilities, and the `ScalarMappable` mixin. | |||
|
|||
See :doc:`/gallery/color/colormap_reference` for a list of builtin colormaps. | |||
See :doc:`/tutorials/colors/colormaps` for an in-depth discussion of colormaps. | |||
- See :doc:`/gallery/color/colormap_reference` for a list of builtin |
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.
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.
No problem - shoudl this be a seealso::
?
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.
Yeah, you could make this a seealso::
.
If you switch to seealso::
the following is just for information: Make sure to write bullet lists exactly like this:
Some paragraph:
- Some long text that is continued on
the next line.
- Some other text.
Normal paragraph again.
- No indent of the bullets with respect to the surronding paragraphs (that's fixed now).
- Continued bulleted lines have to have the text alinged with the text after the bullet (you had extra indentation here.
- There needs to be an empty line before and after the bullet list.
I know this is a bit picky, but that's how restructered text wants it.
plot_examples([viridis, newcmp]) | ||
|
||
############################################################################## | ||
# LinearSegmented colormaps |
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.
-
Would call this "Creating a new LinearSegmentedColormap" in resemblence to "Creating a new ListedColormap".
-
Not sure if we need the "new" in the title.
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.
Retitled
# LinearSegmented colormaps | ||
# ========================= | ||
# | ||
# `.LinearSegmentedColormap` have an alternate way to specify colormaps that |
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.
Alternative wording:
LinearSegmentedColormap specifies the colors using anchor points. The RGB(A) color values for positions in between the anchor points are linearly interpolated from the anchor point RGB(A) 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.
rewritten...
# (RGBA). | ||
# | ||
# The format to specify these colormaps is a bit complicated to allow | ||
# discontinuities at the anchor points. First, with no discontinuities: |
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 the format needs a description here, or at least a "See LinearSegmentedColormap for a description of the format."
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.
new version describes the format.
76b263c
to
04e096f
Compare
4302477
to
e76b41b
Compare
Thanks @timhoffm https://12778-1385122-gh.circle-artifacts.com/0/home/circleci/project/doc/build/html/tutorials/colors/colormap-manipulation.html#sphx-glr-tutorials-colors-colormap-manipulation-py has some reworked stuff, particularly in the LinearSegmentedColormap section. |
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.
The LinearSegmented color map is much cleaner now.
Good to go after the bullet list/seealso in cm.py is fixed.
plot_examples([viridis, newcmp]) | ||
|
||
############################################################################## | ||
# Creating LinearSegmented colormaps |
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 would either use the class name "Creating LinearSegmentedColormaps" or a textual description "Creating linear segmented colormaps" (or maybe "Creating linear-segmented colormaps" I'm never sure when to use a hyphen). In any case no mixture.
Same with "Creating listed colormaps".
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.
Now
- Creating listed colormaps
- Creating linear segmented colormaps
e76b41b
to
84e9f62
Compare
84e9f62
to
e9cda7f
Compare
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |
Thanks! This is a significant improvement on the documentation of colormaps. |
…ipulation DOC: colormap-manipulation tutorial
PR Summary
closes #11903
Shows how to manipulate colormaps.
rendered version 24 Aug: https://12782-1385122-gh.circle-artifacts.com/0/home/circleci/project/doc/build/html/tutorials/colors/colormap-manipulation.html#sphx-glr-tutorials-colors-colormap-manipulation-py
PR Checklist