[WIP] Categorical Color Mapping #6934
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Start of a PR to simplify creating colormaps for categorical data such that (key, value) pairs can be used - and then reused in other functions. Currently using ListedColormap alone requires one to mentally sort the data and then list colors accordingly, as does using ListedColormap+BoundaryNorm, and the latter also requires an upper boundary that is unintuitive for data that isn't interval. This aims to somewhat address #6214 & #6802
This is just a teeny wrapper over colors.ListedColormap and colors.BoundaryNorm (which is probably the wrong thing to do and I should write a CategoryNorm to do 1 int to 1 color mapping) in the style of colors.from_levels_and_colors that allows users to do this:
This is all tentative, but next steps are:
Also, this PR is dependent on #6920 since it uses py.test and branches off of #6889 because it may need those features.
More notes:
Need to change when imshow does it's casting, currently too early
Makes use of StrCategoricalConverter
Conversion gets stashed in Norm, which seems to be the place to do unit stuff on scaler mappables since it's the level at which value mapping happens anyway...