23
23
import iris .cube
24
24
import iris .exceptions
25
25
import iris .plot as iplt
26
- import iris .quickplot as qplt
27
26
import matplotlib .pyplot as plt
28
27
from markdown_it import MarkdownIt
29
28
@@ -49,9 +48,11 @@ def _make_plot_html_page(plot_filename: str) -> None:
49
48
}
50
49
.plot-container {
51
50
width: min(95vw, 95vh);
51
+ height: 99vh;
52
52
}
53
53
.plot-container>img {
54
54
width: 100%;
55
+ height: 100%;
55
56
}
56
57
#description-container {
57
58
flex: 30ch;
@@ -145,12 +146,39 @@ def spatial_contour_plot(
145
146
TypeError
146
147
If cube isn't a Cube.
147
148
"""
149
+ title = get_recipe_metadata ().get ("title" , "Untitled" )
148
150
if not filename :
149
- filename = slugify (get_recipe_metadata (). get ( " title" , "Untitled" ) )
151
+ filename = slugify (title )
150
152
filename = Path (filename ).with_suffix (".svg" )
151
153
cube = _check_single_cube (cube )
152
- qplt .contourf (cube )
153
- plt .savefig (filename )
154
+
155
+ # with mpl.rc_context({"figure.labelsize": 22}):
156
+
157
+ # Setup plot details, size, resolution, etc.
158
+ # Set label size.
159
+ plt .figure (num = 1 , figsize = (15 , 15 ), facecolor = "w" , edgecolor = "k" )
160
+ # fig.tight_layout(pad=0)
161
+
162
+ # plt.rc('xtick',labelsize=22)
163
+ # plt.rc('ytick',labelsize=22)
164
+
165
+ # Filled contour plot of the field.
166
+ iplt .contourf (cube )
167
+
168
+ # Add coastlines.
169
+ plt .gca ().coastlines (resolution = "10m" )
170
+
171
+ # Set plotting limits.
172
+ # plt.xlim(points_x)
173
+ # plt.ylim(points_y)
174
+
175
+ # Add title.
176
+ plt .title (title , fontsize = 16 )
177
+ cbar = plt .colorbar ()
178
+ cbar .set_label (label = f"{ cube .name ()} ({ cube .units } )" , size = 20 )
179
+
180
+ plt .savefig (filename , bbox_inches = "tight" )
181
+
154
182
logging .info ("Saved contour plot to %s" , filename )
155
183
_make_plot_html_page (filename )
156
184
return cube
@@ -214,7 +242,7 @@ def postage_stamp_contour_plot(
214
242
colorbar = plt .colorbar (plot , colorbar_axes , orientation = "horizontal" )
215
243
colorbar .set_label (f"{ cube .name ()} / { cube .units } " )
216
244
217
- plt .savefig (filename )
245
+ plt .savefig (filename , bbox_inches = "tight" )
218
246
logging .info ("Saved contour postage stamp plot to %s" , filename )
219
247
_make_plot_html_page (filename )
220
248
return cube
0 commit comments