redplanet.plot
plot(
lons: ndarray,
lats: ndarray,
dat: ndarray,
ax: None | matplotlib.axes._axes.Axes = None,
figsize: float | tuple[float, float] = (7, 7),
xlabel: str = "Longitude",
ylabel: str = "Latitude",
title: None | str = None,
cmap: str = "RdBu_r",
cbar: bool = True,
cbar_label: None | str = None,
cbar_units: None | str | tuple[str, float] = None,
limits: tuple[None | float, None | float] = [
None,
None,
],
hillshade: bool = False,
topo_model: str = "DEM_463m",
azimuth: int = 0,
altitude: int = 70,
alpha_hs: float = 1,
alpha_dat: float = 0.6,
show: bool = True,
) -> tuple[
matplotlib.figure.Figure, matplotlib.axes._axes.Axes
]
Plots a 2D dataset with optional hillshade underlay.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lons
|
np.ndarray
|
1D array of longitudes, likely the ones used to create the data array. |
required |
lats
|
np.ndarray
|
1D array of latitudes, likely the ones used to create the data array. |
required |
dat
|
np.ndarray
|
2D array of data values to be visualized. Shape should be |
required |
ax
|
None | plt.Axes
|
Existing Matplotlib Axes object on which to plot the data, e.g. if you're using subplots to put multiple plots on the same figure. If None, a new figure and axes are created. Default is None. |
None
|
figsize
|
float | tuple[float, float]
|
Width, height of the figure in inches. If a single number is provided, it is used for both width and height. Default is (7, 7). |
(7, 7)
|
xlabel
|
str
|
Label for the x-axis. Default is 'Longitude'. |
'Longitude'
|
ylabel
|
str
|
Label for the y-axis. Default is 'Latitude'. |
'Latitude'
|
title
|
None | str
|
Title of the plot. If None, no title is set. Default is None. |
None
|
cmap
|
str
|
Colormap used to display the data. Default is 'RdBu_r'. |
'RdBu_r'
|
cbar
|
None | bool
|
Whether to display a colorbar alongside the plot. Default is True. |
True
|
cbar_label
|
None | str
|
Label for the colorbar. Default is None. |
None
|
cbar_units
|
str | tuple[str, float]
|
Units to display on the colorbar. If a tuple is provided, it should be in the form |
None
|
limits
|
tuple[None | float, None | float]
|
Tuple specifying the (minimum, maximum) limits for the data colormap scaling. If you only want to set one limit, use None for the other. Default is [None, None]. |
[None, None]
|
hillshade
|
bool
|
If True, underlays a hillshade generated from topographic data. Default is False. |
False
|
topo_model
|
str
|
(For hillshade) Identifier for the topographic model used to generate the hillshade. See |
'DEM_463m'
|
azimuth
|
int
|
(For hillshade) Azimuth angle (in degrees) representing the horizontal direction of the light source (measured clockwise from north). Default is 0. |
0
|
altitude
|
int
|
(For hillshade) Altitude angle (in degrees) representing the vertical angle of the light source above the horizon. Default is 70. |
70
|
alpha_hs
|
float
|
(For hillshade) Opacity for the hillshade underlay (range 0 to 1). Default is 1. |
1
|
alpha_dat
|
float
|
(For hillshade) Opacity for the data overlay (range 0 to 1). If hillshade is disabled, this is set to 1. Default is 0.6. |
0.6
|
show
|
bool
|
If True and a new figure is created (i.e. |
True
|
Returns:
Type | Description |
---|---|
tuple[plt.Figure, plt.Axes]
|
A tuple containing the matplotlib Figure and Axes objects for the created plot. |
Source code in src/redplanet/helper_functions/plotter.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|