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

Appearance settings

Commit a6cf357

Browse filesBrowse files
authored
Merge pull request #24935 from meeseeksmachine/auto-backport-of-pr-24934-on-v3.7.x
Backport PR #24934 on branch v3.7.x (Swap ipython directives for code-block directives)
2 parents c19b6f5 + b39ef4a commit a6cf357
Copy full SHA for a6cf357

File tree

Expand file treeCollapse file tree

1 file changed

+10
-15
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-15
lines changed

‎tutorials/colors/colormapnorms.py

Copy file name to clipboardExpand all lines: tutorials/colors/colormapnorms.py
+10-15Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
Artists that map data to color pass the arguments *vmin* and *vmax* to
2121
construct a :func:`matplotlib.colors.Normalize` instance, then call it:
2222
23-
.. ipython::
23+
.. code-block:: pycon
2424
25-
In [1]: import matplotlib as mpl
26-
27-
In [2]: norm = mpl.colors.Normalize(vmin=-1, vmax=1)
28-
29-
In [3]: norm(0)
30-
Out[3]: 0.5
25+
>>> import matplotlib as mpl
26+
>>> norm = mpl.colors.Normalize(vmin=-1, vmax=1)
27+
>>> norm(0)
28+
0.5
3129
3230
However, there are sometimes cases where it is useful to map data to
3331
colormaps in a non-linear fashion.
@@ -192,15 +190,12 @@
192190
# lower out-of-bounds values to the range over which the colors are
193191
# distributed. For instance:
194192
#
195-
# .. ipython::
196-
#
197-
# In [2]: import matplotlib.colors as colors
198-
#
199-
# In [3]: bounds = np.array([-0.25, -0.125, 0, 0.5, 1])
200-
#
201-
# In [4]: norm = colors.BoundaryNorm(boundaries=bounds, ncolors=4)
193+
# .. code-block:: pycon
202194
#
203-
# In [5]: print(norm([-0.2, -0.15, -0.02, 0.3, 0.8, 0.99]))
195+
# >>> import matplotlib.colors as colors
196+
# >>> bounds = np.array([-0.25, -0.125, 0, 0.5, 1])
197+
# >>> norm = colors.BoundaryNorm(boundaries=bounds, ncolors=4)
198+
# >>> print(norm([-0.2, -0.15, -0.02, 0.3, 0.8, 0.99]))
204199
# [0 0 1 2 3 3]
205200
#
206201
# Note: Unlike the other norms, this norm returns values from 0 to *ncolors*-1.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.