|
30 | 30 | },
|
31 | 31 | "source": [
|
32 | 32 | "The `~proplot.wrappers.standardize_2d` wrapper is used to standardize the input of a bunch of different plotting functions. \n",
|
33 |
| - "It allows you to optionally omit *x* and *y* coordinates, in which case they are inffered from the data array; guesses graticule edges for `~matplotlib.axes.Axes.pcolor` and `~matplotlib.axes.Axes.pcolormesh` plots; and optionally enforces global data coverage when plotting in map projections. See the documentation for details." |
| 33 | + "It allows you to optionally omit *x* and *y* coordinates, in which case they are inffered from the data array; guesses graticule edges for `~matplotlib.axes.Axes.pcolor` and `~matplotlib.axes.Axes.pcolormesh` plots; and optionally enforces global data coverage when plotting in map projections." |
34 | 34 | ]
|
35 | 35 | },
|
36 | 36 | {
|
37 | 37 | "cell_type": "markdown",
|
38 | 38 | "metadata": {},
|
39 | 39 | "source": [
|
40 |
| - "## Pandas and xarray integration" |
| 40 | + "## Pandas and xarray" |
41 | 41 | ]
|
42 | 42 | },
|
43 | 43 | {
|
|
98 | 98 | "cell_type": "markdown",
|
99 | 99 | "metadata": {},
|
100 | 100 | "source": [
|
101 |
| - "## On-the-fly colormaps" |
102 |
| - ] |
103 |
| - }, |
104 |
| - { |
105 |
| - "cell_type": "raw", |
106 |
| - "metadata": { |
107 |
| - "raw_mimetype": "text/restructuredtext" |
108 |
| - }, |
109 |
| - "source": [ |
110 |
| - "The `~proplot.wrappers.cmap_changer` wrapper allows you to create and apply new colormaps on-the-fly. Just pass the `cmap` keyword argument to any supported plotting method. See :ref:`Making new colormaps` for details. This wrapper also implements the features described in :ref:`Colormap levels`, :ref:`Colormap normalizers`, and :ref:`Pcolor and contour labels` below." |
111 |
| - ] |
112 |
| - }, |
113 |
| - { |
114 |
| - "cell_type": "markdown", |
115 |
| - "metadata": {}, |
116 |
| - "source": [ |
117 |
| - "## Colormap levels" |
| 101 | + "## Discrete colormap levels" |
118 | 102 | ]
|
119 | 103 | },
|
120 | 104 | {
|
|
141 | 125 | "state = np.random.RandomState(51423)\n",
|
142 | 126 | "data = (state.normal(0, 1, size=(33, 33))).cumsum(axis=0).cumsum(axis=1)\n",
|
143 | 127 | "axs.format(suptitle='Pcolor with levels demo')\n",
|
144 |
| - "ax = axs[0]\n", |
145 |
| - "ax.pcolor(data, cmap=cmap, N=200, symmetric=True, colorbar='l')\n", |
146 |
| - "ax.format(title='Ambiguous values', yformatter='null')\n", |
147 |
| - "ax = axs[1]\n", |
148 |
| - "ax.pcolor(data, cmap=cmap, N=10, symmetric=True, colorbar='r')\n", |
149 |
| - "ax.format(title='Discernible levels')" |
| 128 | + "for ax, n, mode, side in zip(axs, (200, 10), ('Ambiguous', 'Discernible'), 'lr'):\n", |
| 129 | + " ax.pcolor(data, cmap=cmap, N=n, symmetric=True, colorbar=side)\n", |
| 130 | + " ax.format(title=f'{mode} values', yformatter='null')" |
150 | 131 | ]
|
151 | 132 | },
|
152 | 133 | {
|
|
179 | 160 | "data = (20*(state.rand(20, 20) - 0.4).cumsum(axis=0).cumsum(axis=1)) % 360\n",
|
180 | 161 | "# Show cyclic colorbar with distinct end colors\n",
|
181 | 162 | "ax = axs[0]\n",
|
182 |
| - "ax.pcolormesh(data, levels=levels, cmap='phase',\n", |
183 |
| - " extend='neither', colorbar='b')\n", |
| 163 | + "ax.pcolormesh(data, levels=levels, cmap='phase', extend='neither',\n", |
| 164 | + " colorbar='b', colorbar_kw={'locator': 90})\n", |
184 | 165 | "ax.format(title='cyclic colormap\\nwith distinct end colors')\n",
|
185 | 166 | "# Show colorbars with different extend values\n",
|
186 | 167 | "for ax, extend in zip(axs[1:], ('min', 'max', 'neither', 'both')):\n",
|
|
193 | 174 | "cell_type": "markdown",
|
194 | 175 | "metadata": {},
|
195 | 176 | "source": [
|
196 |
| - "## Colormap normalizers" |
| 177 | + "## Colormap normalization" |
197 | 178 | ]
|
198 | 179 | },
|
199 | 180 | {
|
|
202 | 183 | "raw_mimetype": "text/restructuredtext"
|
203 | 184 | },
|
204 | 185 | "source": [
|
205 |
| - "If you pass unevenly spaced `levels` to a plotting command, the `~proplot.styletools.LinearSegmentedNorm` normalizer is applied by default. This results in even color gradations across *indices* of the level list, no matter their spacing. To use an arbitrary colormap normalizer, just pass `norm` and optionally `norm_kw` to a command wrapped by `~proplot.wrappers.cmap_changer`. These arguments are passed to the `~proplot.styletools.Norm` constructor." |
| 186 | + "If you pass unevenly spaced `levels` to a plotting command, the `~proplot.styletools.LinearSegmentedNorm` normalizer is applied by default. This results in even color gradations across *indices* of the level list, no matter their spacing. \n", |
| 187 | + "\n", |
| 188 | + "There is a new `~proplot.styletools.MidpointNorm` class that warps your colormap so that its midpoint lies on some central data value, no matter the minimum and maximum colormap colors.\n", |
| 189 | + "\n", |
| 190 | + "To use an arbitrary colormap normalizer, just pass `norm` and optionally `norm_kw` to a command wrapped by `~proplot.wrappers.cmap_changer`. These arguments are passed to the `~proplot.styletools.Norm` constructor." |
206 | 191 | ]
|
207 | 192 | },
|
208 | 193 | {
|
|
213 | 198 | "source": [
|
214 | 199 | "import proplot as plot\n",
|
215 | 200 | "import numpy as np\n",
|
| 201 | + "# Linear segmented norm\n", |
216 | 202 | "f, axs = plot.subplots(ncols=2, axwidth=2.5, aspect=1.5)\n",
|
217 | 203 | "state = np.random.RandomState(51423)\n",
|
218 | 204 | "data = 10**(2*state.rand(20, 20).cumsum(axis=0)/7)\n",
|
|
221 | 207 | " m = axs[i].contourf(data, levels=ticks, extend='both',\n",
|
222 | 208 | " cmap='Mako', norm=norm, colorbar='b')\n",
|
223 | 209 | " axs[i].format(title=title)\n",
|
224 |
| - "axs.format(suptitle='Level normalizers demo')" |
225 |
| - ] |
226 |
| - }, |
227 |
| - { |
228 |
| - "cell_type": "raw", |
229 |
| - "metadata": { |
230 |
| - "raw_mimetype": "text/restructuredtext" |
231 |
| - }, |
232 |
| - "source": [ |
233 |
| - "Finally, there is a new `~proplot.styletools.MidpointNorm` class that warps your colormap so that its midpoint lies on some central data value, no matter the minimum and maximum colormap colors. Again, to use an arbitrary colormap normalizer, just pass `norm` and optionally `norm_kw` to a command wrapped by `~proplot.wrappers.cmap_changer`. These arguments are passed to the `~proplot.styletools.Norm` constructor." |
234 |
| - ] |
235 |
| - }, |
236 |
| - { |
237 |
| - "cell_type": "code", |
238 |
| - "execution_count": null, |
239 |
| - "metadata": {}, |
240 |
| - "outputs": [], |
241 |
| - "source": [ |
242 |
| - "import proplot as plot\n", |
243 |
| - "import numpy as np\n", |
244 |
| - "state = np.random.RandomState(51423)\n", |
| 210 | + "axs.format(suptitle='Level normalizers demo')\n", |
| 211 | + "# Midpoint norm\n", |
245 | 212 | "data1 = (state.rand(20, 20) - 0.43).cumsum(axis=0)\n",
|
246 | 213 | "data2 = (state.rand(20, 20) - 0.57).cumsum(axis=0)\n",
|
247 | 214 | "f, axs = plot.subplots(ncols=2, axwidth=2.5, aspect=1.5)\n",
|
248 | 215 | "cmap = plot.Colormap('Moisture', cut=0.1)\n",
|
249 | 216 | "axs.format(suptitle='Midpoint normalizer demo')\n",
|
250 |
| - "axs[0].contourf(data1, norm='midpoint', cmap=cmap, colorbar='b')\n", |
251 |
| - "axs[0].format(title='Skewed positive data')\n", |
252 |
| - "axs[1].contourf(data2, norm='midpoint', cmap=cmap, colorbar='b')\n", |
253 |
| - "axs[1].format(title='Skewed negative data')" |
| 217 | + "for ax, data, mode in zip(axs, (data1, data2), ('positive', 'negative')):\n", |
| 218 | + " m = ax.contourf(data, norm='midpoint', cmap=cmap)\n", |
| 219 | + " ax.colorbar(m, loc='b', locator=1, minorlocator=0.25)\n", |
| 220 | + " ax.format(title=f'Skewed {mode} data')" |
254 | 221 | ]
|
255 | 222 | },
|
256 | 223 | {
|
|
305 | 272 | "cell_type": "markdown",
|
306 | 273 | "metadata": {},
|
307 | 274 | "source": [
|
308 |
| - "## Heatmaps and covariance matrices" |
| 275 | + "## Heatmap plots" |
309 | 276 | ]
|
310 | 277 | },
|
311 | 278 | {
|
|
0 commit comments