Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Deprecate ListedColormap(..., N=...) parameter#29135

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ksunden merged 2 commits intomatplotlib:mainfromtimhoffm:colormap-N
Nov 20, 2024

Conversation

timhoffm
Copy link
Member

Truncating or repeating the given colors to a specific value of N is not within the scope of colormaps. Instead, users should create an appropriate color list themselves and feed that to ListedColormap.

Also the current behavior can be surprising: It may well be that a given N was intended to truncate, but depending on the list, it could repeat. Repeated colors in a colormap are dangerous / often not intentended because they create an ambiguity in the color -> value mapping.

Truncating or repeating the given colors to a specific value of Nis not within the scope of colormaps. Instead, users shouldcreate an appropriate color list themselves and feed that toListedColormap.Also the current behavior can be surprising: It may well be thata given N was intended to truncate, but depending on the list, itcould repeat. Repeated colors in a colormap are dangerous / oftennot intentended because they create an ambiguity in the color ->value mapping.
@timhoffmtimhoffm added this to thev3.11.0 milestoneNov 14, 2024
@timhoffmtimhoffm marked this pull request as ready for reviewNovember 14, 2024 14:07
@timhoffmtimhoffm mentioned this pull requestNov 14, 2024
8 tasks
Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
@ksundenksunden merged commit2fa9151 intomatplotlib:mainNov 20, 2024
41 of 43 checks passed
@timhoffmtimhoffm deleted the colormap-N branchNovember 20, 2024 20:03
@neutrinoceros
Copy link
Contributor

neutrinoceros commentedNov 26, 2024
edited
Loading

while adapting cmyt to this change, I noticed thatLinearSegmentedColormap still silently accepts the parameterN, shouldn't it be deprecated too ?
(same goes forLinearSegmentedColormap.from_list)

@timhoffm
Copy link
MemberAuthor

The effect / usage ofN inLinearSegmentedColormap is different:

  • ForListedColormap it only cuts or expands the given list of colors, which can easily be done by the user.
  • ForLinearSegmentedColormap,N defines the internal sampling. The input are RGB curves, which may be very coarsly defined via only a few points. Because we don't want interpolate these curves for every color lookup,LinearSegementedColormap internally samples these curves into a lookup table. N controls this sampling. If we would removeN here, that means the user would have to do the sampling, and then we'd be effectively back to aListedColormap. In other words, the added benefit ofLinearSegmentedColormap is that you can specify the RGB curve on a high level, and the colormap does the sampling into a lookup table for you. That fundamentally needsN as a control parameter.

LinearSegmentedColormap.from_list is only a slightly simpler interface that limits the RGB curves to continuous curves (i.e. you cannot have discontinous jumps), it this equally needsN for the internal sampling.

Therefore, there is no plan to discardN forLinearSegmentedColormap.

neutrinoceros reacted with thumbs up emoji

@neutrinoceros
Copy link
Contributor

thanks a lot for this detailed explanation !

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ksundenksundenksunden approved these changes

@rcomerrcomerrcomer approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.11.0
Development

Successfully merging this pull request may close these issues.

4 participants
@timhoffm@neutrinoceros@ksunden@rcomer

[8]ページ先頭

©2009-2025 Movatter.jp