my_code_base.plot.maps¶
Classes¶
Helper class that provides a standard way to create an ABC using |
|
An accessor to handle features and finishing of stereographic plots produced with cartopy. |
Functions¶
|
Add a ruler around a polar stereographic plot. |
|
A decorator to register an accessor for a |
Compute a circle in axes coordinates, which we can use as a boundary for the map. |
Module Contents¶
- class my_code_base.plot.maps.GeoAxesAccessor(ax)[source]¶
Helper class that provides a standard way to create an ABC using inheritance.
- add_coastlines(*args, **kwargs)[source]¶
Add coastlines to the
GeoAxes.- Parameters:¶
- args : list¶
Arguments to be passed to the
coastlines()method ofGeoAxes.- kwargs : dict¶
Keyword arguments to be passed to the
coastlines()method ofGeoAxes.
- add_land(**kwargs)[source]¶
Add land feature to the
GeoAxes.- Parameters:¶
- kwargs : dict¶
Keyword arguments to be passed to the
add_feature()method ofGeoAxes.
- add_ocean(**kwargs)[source]¶
Add ocean feature to the
GeoAxes.- Parameters:¶
- kwargs : dict¶
Keyword arguments to be passed to the
add_feature()method ofGeoAxes.
- geo_axes¶
- class my_code_base.plot.maps.StereographicAxisAccessor(ax)[source]¶
An accessor to handle features and finishing of stereographic plots produced with cartopy. Can handle both
NorthPolarStereoandSouthPolarStereoprojections.- add_coastlines(*args, **kwargs)¶
Add coastlines to the
GeoAxes.- Parameters:¶
- args : list¶
Arguments to be passed to the
coastlines()method ofGeoAxes.- kwargs : dict¶
Keyword arguments to be passed to the
coastlines()method ofGeoAxes.
-
add_features(gridlines=
True, ruler=True, **kwargs)[source]¶ Apply various features to the plot.
Notes
This method applies the following features to the plot:
add ocean
add land
add coastlines
add ruler
make the boundary circular
add gridlines
:glue:`/examples/stereographic_maps.ipynb::polar_plot_features`
- add_gridlines(**kwargs)[source]¶
Add gridlines to the plot.
Notes
This method adds gridlines to the plot using the specified keyword arguments for customization. The default values for the keyword arguments are:
‘zorder’: 1
‘linestyle’: ‘-’
‘linewidth’: 0.5
‘color’: ‘gray’
‘alpha’: 0.7
The gridlines are added based on the latitude limits of the plot. The latitude grid spacing is set to 10 degrees. The longitude grid spacing is determined by the latitude grid spacing and the x_spacing_factor. The gridlines are created using the gridlines method of the geo_axes object. The draw_labels argument is set to True for the first set of gridlines and False for the second set.
- add_land(**kwargs)¶
Add land feature to the
GeoAxes.- Parameters:¶
- kwargs : dict¶
Keyword arguments to be passed to the
add_feature()method ofGeoAxes.
- add_ocean(**kwargs)¶
Add ocean feature to the
GeoAxes.- Parameters:¶
- kwargs : dict¶
Keyword arguments to be passed to the
add_feature()method ofGeoAxes.
- add_ruler(**kwargs)[source]¶
Add a circular ruler to the plot.
See
add_circular_ruler()for customization arguments. The ax argument is not needed to be handed over when using the accessor’s method.
-
rotate_lat_labels(target_lon=
118, orig_lon=150)[source]¶ Move the latitude labels to another longitude.
- rotate_lon_labels()[source]¶
Rotate the longitude labels of a stereographic plot for better readability and nicer look.
- geo_axes¶
- property lat_limits¶
Get and set the latitude limits for the plot.
-
my_code_base.plot.maps.add_circular_ruler(ax, segment_length=
30, offset=0, primary_color='k', secondary_color='w', width=1)[source]¶ Add a ruler around a polar stereographic plot.
- Parameters:¶
- ax : GeoAxes¶
The GeoAxes object to which the ruler should be added
- segment_length : int¶
The length of each segment in degrees
- offset : int¶
An optional offset
- primary_color : str¶
The color of the background ruler segments
- secondary_color : str¶
The color of the top ruler segments
- width : float¶
The scaled thickness of the ruler. Defaults to 1/80 of the axes’ width.
- my_code_base.plot.maps.register_geoaxes_accessor(accessor_name)[source]¶
A decorator to register an accessor for a
cartopy.mpl.geoaxes.GeoAxesobject.Example
>>> pytest.skip() >>> @register_geoaxes_accessor("my_accessor") >>> class MyCustomAccessor: >>> def some_method(self): >>> pass >>> >>> ax = plt.subplot(projection=cartopy.crs.NorthPolarStereo()) >>> ax.my_accessor.some_method()