@@ -4,21 +4,22 @@ Colormap Normaliztions
44================================
55
66Objects that use colormaps usually linearly map the colors in the
7- colormap from data values `` vmin `` to `` vmax `` . For example::
7+ colormap from data values * vmin * to * vmax * . For example::
88
99 pcm = ax.pcolormesh(x, y, Z, vmin=-1., vmax=1., cmap='RdBu_r')
1010
11- will map the data in *Z * linearly from ` -1 ` to ` +1 ` , so *Z=0 * will
11+ will map the data in *Z * linearly from -1 to +1 , so *Z=0 * will
1212give a color at the center of the colormap *RdBu_r * (white in this
1313case).
1414
15- Normalizations are defined as part of :func: `matplotlib.colors `
16- module. The default normalization is
15+ Matplotlib does this mapping in two steps, with a normalization from
16+ [0,1] occuring first, and then mapping onto the indices in the
17+ colormap. Normalizations are defined as part of
18+ :func: `matplotlib.colors ` module. The default normalization is
1719:func: `matplotlib.colors.Normalize `. The artists that map data to
18- color pass the arguments ``vmin `` and ``vmax `` to
19- :func: `matplotlib.colors.Normalize `. We can
20- substnatiate the normalization and see what it returns. In this case
21- it returns 0.5::
20+ color pass the arguments *vmin * and *vmax * to
21+ :func: `matplotlib.colors.Normalize `. We can substnatiate the
22+ normalization and see what it returns. In this case it returns 0.5::
2223
2324 norm = mpl.colors.Normalize(vmin=-1., vmax=1.)
2425 norm(0.)
@@ -32,10 +33,10 @@ Logarithmic
3233One of the most common transformations is to plot data by taking its
3334logarithm (to the base-10). This transofrmation is useful when there
3435are changes across disparate scales that we still want to be able to
35- see. Using :func: `colors.LogNorm ` normalizes the data by :math: `log_{ 10 }`. In
36- the example below, there are two bumps, one much smaller than the
37- other. Using :func: `colors.LogNorm `, the shape and location of each
38- bump can clearly be seen:
36+ see. Using :func: `colors.LogNorm ` normalizes the data by
37+ :math: `log_{ 10 }`. In the example below, there are two bumps, one much
38+ smaller than the other. Using :func: `colors.LogNorm `, the shape and
39+ location of each bump can clearly be seen:
3940
4041.. plot :: users/plotting/examples/colormap_normalizations_lognorm.py
4142 :include-source:
@@ -46,8 +47,9 @@ Symetric logarithmic
4647Similarly, it sometimes happens that there is data that is positive
4748and negative, but we would still like a logarithmic scaling applied to
4849both. In this case, the negative numbers are also scaled
49- logarithmically, and mapped to small numbers. i.e. If `vmin=-vmax `, then
50- they the negative numbers are mapped from 0 to 0.5.
50+ logarithmically, and mapped to small numbers. i.e. If `vmin=-vmax `,
51+ then they the negative numbers are mapped from 0 to 0.5 and the
52+ positive from 0.5 to 1.
5153
5254Since the values close to zero tend toward infinity, there is a need
5355to have a range around zero that is linear. The parameter *linthresh *
@@ -74,7 +76,7 @@ normalization):
7476 There should probably be a good reason for plotting the data using
7577 this type of transformation. Technical viewers are used to linear
7678 and logarithmic axes and data transformations. Power laws are less
77- common, and readers should explictly be made aware that they have
79+ common, and viewers should explictly be made aware that they have
7880 been used.
7981
8082
@@ -85,17 +87,18 @@ normalization):
8587Custom normalization: Two linear ranges
8688-----------------------------------------
8789
88- It is possible to define your own normalization, as shown in the
89- example below. This example is plotting the same data as the
90- :func: ` colors:SymLogNorm ` example, but this time a different linear
91- map is used for the negative number than the positive. (Note that
92- this example is simple, and does not account for the edge cases like
93- masked data or invalid values of * vmin * and *vmax *)
90+ It is possible to define your own normalization. This example
91+ plots the same data as the :func: ` colors:SymLogNorm ` example, but
92+ a different linear map is used for the negative data values than
93+ the positive. (Note that this example is simple, and does not account
94+ for the edge cases like masked data or invalid values of * vmin * and
95+ *vmax *)
9496
9597.. note ::
98+ This may appear soon as :func: `colors.OffsetNorm `
9699
97100 As above, non-symetric mapping of data to color is non-standard
98- practice, and should be used advisedly.
101+ practice, and should only be used advisedly.
99102
100103.. plot :: users/plotting/examples/colormap_normalizations_custom.py
101104 :include-source:
@@ -111,10 +114,10 @@ instance, if ::
111114
112115 bounds = np.array([-0.25, -0.125, 0, 0.5, 1])
113116 norm = colors.BoundaryNorm(boundaries=bounds, ncolors=4)
114- print norm([-0.2,-0.15,-0.02,0.3, 0.8, 0.99])
117+ print norm([-0.2,-0.15,-0.02, 0.3, 0.8, 0.99])
115118
116119This returns: [0, 0, 1, 2, 3, 3]. Note unlike the other norms, this
117- one returns values from 0 to *ncolors *-1.
120+ norm returns values from 0 to *ncolors *-1.
118121
119122
120123.. plot :: users/plotting/examples/colormap_normalizations_bounds.py
0 commit comments