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

Swap ipython directives for code-block directives#24934

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
jklymak merged 1 commit intomatplotlib:mainfromksunden:rm_ipy_directive
Jan 10, 2023
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletionstutorials/colors/colormapnorms.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,14 +20,12 @@
Artists that map data to color pass the arguments *vmin* and *vmax* to
construct a :func:`matplotlib.colors.Normalize` instance, then call it:

..ipython::
..code-block:: pycon

In [1]: import matplotlib as mpl

In [2]: norm = mpl.colors.Normalize(vmin=-1, vmax=1)

In [3]: norm(0)
Out[3]: 0.5
>>> import matplotlib as mpl
>>> norm = mpl.colors.Normalize(vmin=-1, vmax=1)
>>> norm(0)
0.5

However, there are sometimes cases where it is useful to map data to
colormaps in a non-linear fashion.
Expand DownExpand Up@@ -192,15 +190,12 @@
# lower out-of-bounds values to the range over which the colors are
# distributed. For instance:
#
# .. ipython::
#
# In [2]: import matplotlib.colors as colors
#
# In [3]: bounds = np.array([-0.25, -0.125, 0, 0.5, 1])
#
# In [4]: norm = colors.BoundaryNorm(boundaries=bounds, ncolors=4)
# .. code-block:: pycon
#
# In [5]: print(norm([-0.2, -0.15, -0.02, 0.3, 0.8, 0.99]))
# >>> import matplotlib.colors as colors
# >>> bounds = np.array([-0.25, -0.125, 0, 0.5, 1])
# >>> norm = colors.BoundaryNorm(boundaries=bounds, ncolors=4)
# >>> print(norm([-0.2, -0.15, -0.02, 0.3, 0.8, 0.99]))
# [0 0 1 2 3 3]
#
# Note: Unlike the other norms, this norm returns values from 0 to *ncolors*-1.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp