8000 A method added to Colormap classes to reverse the colormap by kjartankg · Pull Request #6211 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

A method added to Colormap classes to reverse the colormap #6211

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 3 commits into from
Mar 27, 2016

Conversation

kjartankg
Copy link
Contributor

This implements a solution for issue #4271

  • method added to both ListedColormap and LinearSegmentedColormap
  • The parent class Colormap raises NotImplementedError
  • A test was added to test_colors.py

This PR succeeds PR #5899. Following is the initial comment copy/pasted from the previous PR:

A few things that I ran into while implementing this:

  • Functions to reverse Colormap data already existed in matplotlib.cm but they are inconvenient for a user. After seeing that I changed my implementation to resemble them more. Perhaps the old functions should eventually be deprecated?
  • The documentation for LinearSegmentedColormap does not mention that input data can be functions. It is mentioned briefly in the doc for makeMappingArray but should probably be mentioned in the doc for LinearSegmentedColormap.
  • The data is specified as "list of tuples" LinearSegmentedColormap and ListedColormap "a list of matplotlib color specifications, or an equivalent Nx3 or Nx4 floating point array (N rgb or rgba values)". I would suggest that this would be changed to array_like and that the data is then copied into a numpy array for internal use.

figure_1
figure_2
figure_3
figure_4
figure_5
figure_6

* method added to both ListedColormap and LinearSegmentedColormap
* The parent class Colormap raises NotImplementedError
* A test was added to test_colors.py
@kjartankg
Copy link
Contributor Author

Looking at the Tracis CI test, I understand the pep8 failure (missing a blank line in the test_colors.py) but the other failure I don't understand. Can someone explain that to me? It seems to be unrelated to what I've done in this PR.

@QuLogic QuLogic added this to the 2.1 (next point release) milestone Mar 23, 2016
@mdboom
Copy link
Member
mdboom commented Mar 23, 2016

The other failure is testing against Numpy nightlies, which is known to be broken. It's an optional test, though -- it doesn't cause the whole thing to fail when it fails.

@mdboom
Copy link
Member
mdboom commented Mar 23, 2016

Cc: @efiring

@efiring
Copy link
Member
efiring commented Mar 23, 2016

Based on a quick look, I think this looks promising.

"""
Make a reversed instance of the Colormap.

NOTE: Function not implemented for base class.
Copy link
Member

Choose a reason for hiding this comment

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

Use .. note :: and sphinx will render this better.

@tacaswell
Copy link
Member

Can you also add a note in whats_new https://github.com/matplotlib/matplotlib/tree/master/doc/users/whats_new ?

* NOTE: cnaged to .. note ::
* Raises section removed Colormap.reversed docstring
* methods mentioned in a new file under whats_new
@tacaswell tacaswell merged commit 6f27f95 into matplotlib:master Mar 27, 2016
@tacaswell
Copy link
Member

@kjartankg Thanks! I think this is your first contribution to mpl, congratulations! Hope we hear from you again.

@kjartankg
Copy link
Contributor Author

Excellent, thanks! I will most likely have a look at some more things. @tacaswell if there's anything specific that needs to be worked on feel free to point me in that direction. Otherwise I will just browse the issues again.

@kjartankg kjartankg deleted the reverse-cm branch March 27, 2016 14:27
@tacaswell
Copy link
Member

Browsing the issues / fixing itches you encounter day-to-day is the best place to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0