easyclimate.plot.quick_draw¶
The quick drawing function
Functions¶
|
Create geographical and spatial base map. |
|
Create geographical rectangular box. |
|
Create a custom geographical rectangular box with optional rotation. |
Module Contents¶
- easyclimate.plot.quick_draw.quick_draw_spatial_basemap(nrows: int = 1, ncols: int = 1, figsize=None, central_longitude: float = 0.0, draw_labels: str | bool | list | dict = ['bottom', 'left'], gridlines_color: str = 'grey', gridlines_alpha: float = 0.5, gridlines_linestyle: str = '--', coastlines_edgecolor: str = 'black', coastlines_kwargs: dict = {'lw': 0.5})¶
Create geographical and spatial base map.
Parameters¶
- nrows, ncols
int, default: 1 Number of rows/columns of the subplot grid.
- figsize: (
float,float) Width, height in inches.
- central_longitude:
float, default: 0. The central longitude for cartopy.crs.PlateCarree projection.
- draw_labels:
str|bool|list|dict, default: [“bottom”, “left”]. Toggle whether to draw labels. For finer control, attributes of Gridliner may be modified individually.
string: “x” or “y” to only draw labels of the respective coordinate in the CRS.
list: Can contain the side identifiers and/or coordinate types to select which ones to draw. For all labels one would use [“x”, “y”, “top”, “bottom”, “left”, “right”, “geo”].
dict: The keys are the side identifiers (“top”, “bottom”, “left”, “right”) and the values are the coordinates (“x”, “y”); this way you can precisely decide what kind of label to draw and where. For x labels on the bottom and y labels on the right you could pass in {“bottom”: “x”, “left”: “y”}.
Note that, by default, x and y labels are not drawn on left/right and top/bottom edges respectively unless explicitly requested.
- gridlines_color:
str, default: grey. The parameter color for ax.gridlines.
- gridlines_alpha:
float, default: 0.5. The parameter alpha for ax.gridlines.
- gridlines_linestyle:
str, default: “–”. The parameter linestyle for ax.gridlines.
- coastlines_edgecolor:
str, default: “black”. The parameter color for ax.coastlines.
- coastlines_kwargs:
float, default:{"lw": 0.5}. The kwargs for ax.coastlines.
Returns¶
fig:
Figureax:
Axesor array of Axes: ax can be either a singleAxesobject, or an array of Axes objects if more than one subplot was created. The dimensions of the resulting array can be controlled with the squeeze keyword.
See also
matplotlib.pyplot.subplotscartopy.mpl.geoaxes.GeoAxes.gridlinescartopy.mpl.geoaxes.GeoAxes.coastlines- nrows, ncols
- easyclimate.plot.quick_draw.quick_draw_standard_rectangular_box(lon1: float, lon2: float, lat1: float, lat2: float, ax: matplotlib.axes.Axes = None, **patches_kwargs)¶
Create geographical rectangular box.
Parameters¶
- lon1, lon2:
float. Rectangular box longitude point. The applicable value should be between -180 \(^\circ\) and 360 \(^\circ\). lon1 and lon2 must have a certain difference, should not be equal, do not strictly require the size relationship between lon1 and lon2.
- lat1, lat2:
float. Rectangular box latitude point. The applicable value should be between -90 \(^\circ\) and 90 \(^\circ\). lat1 and lat2 must have a certain difference, should not be equal, do not strictly require the size relationship between lat1 and lat2.
- ax
matplotlib.axes.Axes, optional. Axes on which to plot. By default, use the current axes. Mutually exclusive with size and figsize.
- **patches_kwargs:
Patch properties. see more in
matplotlib.patches.Patch
See also
- lon1, lon2:
- easyclimate.plot.quick_draw.quick_draw_custom_rectangular_box(lon1: float, lon2: float, lat1: float, lat2: float, ax: matplotlib.axes.Axes = None, angle: float = 0.0, center: Literal['center', 'lowerleft'] = 'center', geo: bool = True, lat0: float | None = None, **patches_kwargs)¶
Create a custom geographical rectangular box with optional rotation.
Parameters¶
- lon1, lon2:
float. Rectangular box longitude point. The applicable value should be between -180 \(^\circ\) and 360 \(^\circ\). lon1 and lon2 are used to define the unrotated box extent, and do not strictly require the size relationship between them.
- lat1, lat2:
float. Rectangular box latitude point. The applicable value should be between -90 \(^\circ\) and 90 \(^\circ\). lat1 and lat2 are used to define the unrotated box extent, and do not strictly require the size relationship between them.
- ax
matplotlib.axes.Axes, optional. Axes on which to plot. By default, use the current axes.
- angle:
float, default: 0.0. Counterclockwise rotation angle in degrees.
- center:
str, default: “center”. Rotation pivot of the rectangular box.
“center”: rotate around the box center.
“lowerleft”: rotate around the lower-left corner of the box.
- geo:
bool, default: True. Whether to apply local geographical metric correction before rotation. If True, longitude is scaled by \(\cos(lat0)\) so that longitude and latitude have a locally comparable distance scale.
- lat0:
float, optional. Reference latitude used when geo=True for the longitude scaling. If None, the center latitude of the rectangular box is used.
- **patches_kwargs:
Patch properties. see more in
matplotlib.patches.Patch
Returns¶
- poly:
Polygon The polygon patch added to the axes.
- poly:
- corners_rot:
numpy.ndarray Rotated corner coordinates of shape (4, 2) in longitude-latitude order.
- corners_rot:
See also
- lon1, lon2: