|
15 | 15 | 5. Creating composite plots
|
16 | 16 | 6. Plot multiple Evaluation Results
|
17 | 17 |
|
| 18 | +
|
| 19 | +Please refer to the :ref:`Plotting API Reference <api-plot-functions>` for a description of all |
| 20 | +PyCSEP plotting functionality. |
18 | 21 | """
|
19 | 22 |
|
20 | 23 | ################################################################################################################
|
21 |
| -# Example 1: Spatial dataset plot arguments |
22 |
| -# ----------------------------------------- |
| 24 | +# |
| 25 | +# .. _tutorial-plot-customizations-ex1: |
| 26 | +# |
| 27 | +# Example 1: Customizing Gridded Dataset Plot |
| 28 | +# ------------------------------------------- |
23 | 29 |
|
24 | 30 | ####################################################################################################################################
|
25 | 31 | # **Load required libraries**
|
|
49 | 55 | # * Assign a title
|
50 | 56 | # * Set labels to the geographic axes
|
51 | 57 | # * Draw country borders
|
52 |
| -# * Set a linewidth of 0.5 to country border |
53 |
| -# * Assign ``'rainbow'`` as the colormap. Possible values from ``matplotlib.cm`` library |
| 58 | +# * Set a linewidth of 1.5 to country border |
| 59 | +# * Assign ``'rainbow'`` as the colormap. Possible values from :mod:`matplotlib.cm` library |
54 | 60 | # * Defines 0.8 for an exponential transparency function (default is 0 for constant alpha, whereas 1 for linear).
|
55 |
| -# * An object cartopy.crs.Projection() is passed as Projection to the map |
| 61 | +# * An object :class:`cartopy.crs.Projection` (in this case :class:`cartopy.crs.Mercator`) is passed to the map |
56 | 62 | #
|
57 | 63 | # The complete description of plot arguments can be found in :func:`csep.utils.plots.plot_gridded_dataset`
|
58 | 64 | #
|
|
70 | 76 | show=True)
|
71 | 77 |
|
72 | 78 | ####################################################################################################################################
|
| 79 | +# |
| 80 | +# .. _tutorial-plot-customizations-ex2: |
| 81 | +# |
73 | 82 | # Example 2: Plot a global forecast and a selected magnitude bin range
|
74 | 83 | # --------------------------------------------------------------------
|
75 | 84 | #
|
|
105 | 114 | ####################################################################################################################################
|
106 | 115 | # **Plotting the dataset**
|
107 | 116 | #
|
108 |
| -# To plot a global forecast, we must assign the option ``set_global=True``, which is required by :ref:`cartopy` to handle |
| 117 | +# To plot a global forecast, we must assign the option ``set_global=True``, which is required by :mod:`cartopy` to handle |
109 | 118 | # internally the extent of the plot. We can further customize the plot using the required arguments from :func:`~csep.utils.plots.plot_gridded_dataset`
|
110 | 119 | #
|
111 | 120 |
|
|
131 | 140 |
|
132 | 141 |
|
133 | 142 | ####################################################################################################################################
|
| 143 | +# |
| 144 | +# .. _tutorial-plot-customizations-ex3: |
| 145 | +# |
134 | 146 | # Example 3: Plot a catalog with a custom basemap
|
135 | 147 | # -----------------------------------------------
|
136 | 148 |
|
|
152 | 164 | # * Set minimum and maximum marker size of 7 and 500, respectively.
|
153 | 165 | # * Set the marker color red
|
154 | 166 | # * Set a 0.3 transparency
|
155 |
| -# * mag_scale is used to exponentially scale the size with respect to magnitude. Recommended 1-8 |
| 167 | +# * `power` is used to exponentially scale the size with respect to magnitude. Recommended 1-8 |
156 | 168 | # * Set legend True and location in 3 (lower-left corner)
|
157 | 169 | # * Set a list of magnitude ticks to display in the legend
|
158 | 170 | #
|
|
165 | 177 | 'max_size': 500,
|
166 | 178 | 'markercolor': 'red',
|
167 | 179 | 'alpha': 0.3,
|
168 |
| - 'mag_scale': 8, |
| 180 | + 'power': 4, |
169 | 181 | 'legend': True,
|
170 | 182 | 'legend_loc': 3,
|
171 | 183 | 'coastline': False,
|
|
178 | 190 |
|
179 | 191 | ax = catalog.plot(show=True, **plot_args)
|
180 | 192 |
|
| 193 | +#################################################################################################################################### |
| 194 | +# Alternatively, it can be plotted using the :func:`csep.utils.plots.plot_catalog` function |
| 195 | + |
| 196 | +plots.plot_catalog(catalog=catalog, show=True, **plot_args) |
181 | 197 |
|
182 | 198 | ####################################################################################################################################
|
| 199 | +# |
| 200 | +# .. _tutorial-plot-customizations-ex4: |
| 201 | +# |
183 | 202 | # Example 4: Plot composition
|
184 | 203 | # -----------------------------------------------
|
185 | 204 | #
|
|
205 | 224 | # Plot the basemap alone by using :func:`csep.utils.plots.plot_basemap`. Do not set ``show=True`` and store the returned ``ax`` object to
|
206 | 225 | # start the composite plot
|
207 | 226 |
|
| 227 | +# Start the base plot |
208 | 228 | ax = plots.plot_basemap(figsize=(8, 8),
|
209 | 229 | projection=cartopy.crs.AlbersEqualArea(central_longitude=-120.),
|
210 | 230 | extent=forecast.region.get_bbox(),
|
|
217 | 237 | ax = forecast.plot(colormap='PuBu_r', alpha_exp=0.5, ax=ax)
|
218 | 238 |
|
219 | 239 | # Use show=True to finalize the composite.
|
220 |
| -catalog.plot(markercolor='darkred', ax=ax, show=True) |
| 240 | +plots.plot_catalog(catalog=catalog, markercolor='darkred', ax=ax, show=True) |
221 | 241 |
|
222 | 242 | ####################################################################################################################################
|
| 243 | +# |
| 244 | +# .. _tutorial-plot-customizations-ex5: |
| 245 | +# |
223 | 246 | # Example 5: Plot multiple evaluation results
|
224 | 247 | # -------------------------------------------
|
225 | 248 |
|
|
0 commit comments