Plotting
This module contains functionality to comfortably create plots.
- mastersign.datascience.plot.bar(data: DataFrame | Series, value_column=None, label_column=None, color_column=None, cmap=None, color=None, xlabel=None, ylabel=None, title=None, figsize=(10, 4), pad=1, pos=(0, 0), rowspan=1, colspan=1, file_name=None, file_dpi=300)[source]
Display a bar chart from columns in a DataFrame or a Series.
- Parameters:
data – A Pandas DataFrame or Series.
value_column – The column with the values for the bars height.
label_column – The column with the labels for the bars. (optional)
color_column – The column with a numeric value for choosing a color from a color map or strings for explicit colors. (optional)
cmap – The name of a color map to use with color_column. (optional)
color – A color for all bars or a list with colors. (optional) color_column superseeds color.
xlabel – The label for the X axis. (optional)
ylabel – The label for the Y axis. (optional)
title – The title of the plot. (optional)
figsize – The figure size in inches. (optional)
pad – Padding around the figure. (optional)
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.bar_groups(data: DataFrame, value_column, key_column, keys=None, label_column=None, color_column=None, cmap=None, color=None, stacked=False, relative=False, xlabel=None, ylabel=None, title=None, legend=True, figsize=(10, 4), pad=1, pos=(0, 0), rowspan=1, colspan=1, file_name=None, file_dpi=300)[source]
Display a bar chart with grouped bars from columns in a DataFrame.
- Parameters:
data – A Pandas DataFrame.
value_column – The column with the values for the bars height.
key_column – The column with the key to group by.
keys – A list with group keys to select. (optional) By default the group keys are taken from the key column and sorted alphabetically.
label_column – The column with the labels for the bars. (optional)
color_column – The column with a numeric value for choosing a color from a color map or strings for explicit colors. (optional)
cmap – The name of a color map to use with color_column. (optional)
color – A list or dict with colors for the groups. (optional) color_column superseeds color.
stacked – A switch to stack the bars. (optional)
relative – A switch to show relative portions with stacked bars. (optional)
legend – A switch to control the visibility of the legend. (optional)
xlabel – The label for the X axis. (optional)
ylabel – The label for the Y axis. (optional)
title – The title of the plot. (optional)
figsize – The figure size in inches. (optional)
pad – Padding around the figure. (optional)
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.begin(figsize=(10, 5), grid=(1, 1))[source]
Begins a figure with multiple subplots.
- Parameters:
figsize – A tuple with the figure size in inches (width, height). (optional)
grid – The grid size to place the subplots in (rows, columns). (optional)
- mastersign.datascience.plot.end(pad=1.5, w_pad=None, h_pad=None, file_name=None, file_dpi=300)[source]
Finalizes a figure with multiple subplots.
- Parameters:
pad – Padding around the figure. (optional)
w_pad – Horizontal space between subplots. (optional) See matplotlib.pyplot.tight_layout().
h_pad – Vertical space between subplots. (optional) See matplotlib.pyplot.tight_layout().
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.hist(data: DataFrame | Series, column=None, key_column=None, bins=35, ticks=None, xmin=None, xmax=None, ylog=False, color=None, cumulative=False, stacked=False, xlabel=None, ylabel=None, title=None, legend=True, figsize=(10, 4), pad=1, pos=(0, 0), rowspan=1, colspan=1, file_name=None, file_dpi=300)[source]
Display a histogram for the values of one column in a DataFrame or a Series. If using a DataFrame, optionally group the values by another key column.
- Parameters:
data – A Pandas DataFrame or Series.
column – The column to build the histogram of.
key_column – The column to group the values by. (optional)
bins – The bins of the histogram (int or sequence or str). (optional) See argument bins of matplotlib.axes.Axes.hist() for more details.
ticks – A sequence of tick positions on the X axis. (optional)
xmin – The lower limit for displayed values (inclusive). (optional)
xmax – The upper limit for displayed values (exclusive). (optional)
ylog – A switch to use a logarithmic scale on the Y axis (optional)
color – A color for all bars, a list with a color per bar (cycled if too short), or a list with one color per key if key_column is used. (optional)
cumulative – A switch to activate cumulative summing. (optional)
stacked – A switch to stack bars if key_column is used. (optional)
xlabel – The label for the X axis. (optional)
ylabel – The label for the Y axis. (optional)
title – The title of the plot. (optional)
legend – A switch to control the visibility of the legend. (optional)
figsize – The figure size in inches. (optional)
pad – Padding around the figure. (optional)
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.hist2d(data: DataFrame, xcolumn, ycolumn, xmin=None, xmax=None, ymin=None, ymax=None, bins=20, xticks=None, yticks=None, cmap='Blues', colorbar=True, xlabel=None, ylabel=None, title=None, figsize=(7.5, 6), pad=1, pos=(0, 0), rowspan=1, colspan=1, file_name=None, file_dpi=300)[source]
Displays a 2-dimensional histogram (heatmap).
- Parameters:
data – A Pandas DataFrame.
xcolumn – The column for the horizontal dimension.
ycolumn – The column for the vertical dimension.
xmin – The lower limit for displayed values in the horizontal dimension (inclusive). (optional)
xmax – The upper limit for displayed values in the horizontal dimension (exclusive). (optional)
ymin – The lower limit for displayed values in the vertical dimension (inclusive). (optional)
ymax – The upper limit for displayed values in the vertical dimension (exclusive). (optional)
bins – None or int or [int, int] or array_like or [array, array]. (optional) See matplotlib.pyplot.hist2d() for more info.
xticks – A sequence of tick positions on the X axis. (optional)
yticks – A sequence of tick positions on the Y axis. (optional)
cmap – A Matplotlib Colormap or the name of a color map. (optional) See matplotlib.pyplot.hist2d() for more info.
colorbar – A switch to control if a colorbar is shown. (optional)
xlabel – A label for the X axis. (optional)
ylabel – A label for Y axis. (optional)
title – A title for the plot. (optional)
figsize – The figure size in inches. (optional)
pad – Padding around the figure. (optional)
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.hist2d_matrix(data: DataFrame, columns=None, mins=None, maxs=None, bins=None, ticks=None, subplot_size=2, pad=1, w_pad=1.0, h_pad=1.75, cmap='Blues', file_name=None, file_dpi=300)[source]
Plots a matrix of 2D histogram plots and histograms for a number of columns from a Pandas DataFrame.
Warning: This function cannot be used between begin() and end() as part of another multiplot.
- Parameters:
data – A Pandas DataFrame.
columns – The columns to include into the matrix. (optional)
mins – A dict, mapping column names to minimal values. (optional)
maxs – A dict, mapping column names to maximal values. (optional)
bins – A dict, mapping column names to bins. (optional)
ticks – A dict, mapping column names to ticks. (optional)
subplot_size – The edge length for the subplots. (optional)
pad – Padding around the figure. (optional)
w_pad – Horizontal space between subplots. (optional)
h_pad – Vertical space between subplots. (optional)
cmap – The color map to use. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.line(data: DataFrame | Series, column=None, xcolumn=None, color=None, linewidth=2, avg_window=None, interpolation_step=None, interpolation_kind='quadratic', xmin=None, xmax=None, ymin=None, ymax=None, xticks=None, yticks=None, xlabel=None, ylabel=None, title=None, figsize=(10, 5), pad=1, pos=(0, 0), rowspan=1, colspan=1, file_name=None, file_dpi=300)[source]
Display a line from values in one column of a DataFrame or a Series.
If data is a Series, the index will be used for the horizontal dimension.
- Parameters:
data – A Pandas DataFrame or a Series.
column – The column with the values to display as a line. The values are used as vertical dimension.
xcolumn – A column with values for the horizontal dimension. (optional)
color – A color for the line. (optional)
linewidth – The width of the line.
avg_window – The size of a window for smoothing the values with a sliding average. (optional)
interpolate_step – A step size in the horizontal dimension, for smoothing the line with interpolation.
interpolate_kind – The kind of interpolation to use: quadratic or cubic. (optional) Has an effect only if interpolation_step is used.
xmin – The lower limit for displayed values in the horizontal dimension. (optional)
xmax – The upper limit for displayed values in the horizontal dimension. (optional)
ymin – The lower limit for displayed values in the vertical dimension. (optional)
ymax – The upper limit for displayed values in the vertical dimension. (optional)
xticks – A sequence of tick positions on the X axis. (optional)
yticks – A sequence of tick positions on the Y axis. (optional)
xlabel – A label for the X axis. (optional)
ylabel – A label for Y axis. (optional)
title – A title for the plot. (optional)
figsize – The figure size in inches. (optional)
pad – Padding around the figure. (optional)
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.lines(data: DataFrame, column, xcolumn=None, key_column=None, min_n=None, label_column=None, color=None, linewidth=2, avg_window=None, interpolation_step=None, interpolation_kind='quadratic', xmin=None, xmax=None, ymin=None, ymax=None, xticks=None, yticks=None, xlabel=None, ylabel=None, title=None, legend=True, figsize=(10, 5), pad=1, pos=(0, 0), rowspan=1, colspan=1, file_name=None, file_dpi=300)[source]
Display line(s) from values in one column of a DataFrame.
- Parameters:
data – A Pandas DataFrame.
column – The column with the values to display as a line. The values are used as vertical dimension.
xcolumn – A column with values for the horizontal dimension. (optional)
key_column – A column for grouping without labels.
label_column – A column for grouping with labels.
min_n – The minimum number of values, required in a group for it to get drawn by a line. (optional)
color – A color for the line(s). (optional)
linewidth – The width of the line(s).
avg_window – The size of a window for smoothing the values with a sliding average. (optional)
interpolate_step – A step size in the horizontal dimension, for smoothing the line with interpolation.
interpolate_kind – The kind of interpolation to use: quadratic or cubic. (optional) Has an effect only if interpolation_step is used.
xmin – The lower limit for displayed values in the horizontal dimension. (optional)
xmax – The upper limit for displayed values in the horizontal dimension. (optional)
ymin – The lower limit for displayed values in the vertical dimension. (optional)
ymax – The upper limit for displayed values in the vertical dimension. (optional)
xticks – A sequence of tick positions on the X axis. (optional)
yticks – A sequence of tick positions on the Y axis. (optional)
xlabel – A label for the X axis. (optional)
ylabel – A label for Y axis. (optional)
title – A title for the plot. (optional)
legend – A switch to control the appearance of a legend. (optional)
figsize – The figure size in inches. (optional)
pad – Padding around the figure. (optional)
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.pie(data: DataFrame | Series, column=None, label_column=None, color_column=None, color=None, startangle=180, counterclock=False, sort_by=None, title=None, pct=True, figsize=(4, 4), pad=1, pos=(0, 0), rowspan=1, colspan=1, file_name=None, file_dpi=300)[source]
Display a pie chart with values from a column in a DataFrame or a Series.
- Parameters:
data – A Pandas DataFrame or Series.
column – The column to use if data is a DataFrame.
label_column – A column to use for the labels. (optional) By default the index is used.
color_column – A column with color names or RGB hex values. (optional)
color – A list or dict for the colors in the pie. (optional) If it is a dict the keys are the labels. Gets overridden by color_column.
sort_by – The sort mode None, “label”, or “value” (optional)
startangle – The start angle in degrees. (optional)
counterclock – A switch to control the angular order. (optional)
title – The title of the plot. (optional)
pct – A switch to display percentages. (optional)
figsize – The figure size in inches. (optional)
pad – Padding around the figure. (optional)
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.pie_groups(data: DataFrame | Series, column=None, sort_by=None, startangle=180, counterclock=False, title=None, pct=True, color=None, figsize=(4, 4), pad=1, pos=(0, 0), rowspan=1, colspan=1, file_name=None, file_dpi=300)[source]
Display a pie chart by counting rows according to a column value from a DataFrame or values from a Series.
- Parameters:
data – A Pandas DataFrame or Series.
column – The column to use for grouping.
sort_by – The sort mode None, “label”, or “value”
startangle – The start angle in degrees. (optional)
counterclock – A switch to control the angular order. (optional)
title – The title of the plot.
pct – A switch to display percentages.
color – A list or dict for the colors in the pie. (optional) If it is a dict the groups are the labels.
figsize – The figure size in inches. (optional)
pad – Padding around the figure. (optional)
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.reset_figure_handler()[source]
Reset the handler, which is called after rendering every plot, to the default.
- mastersign.datascience.plot.scatter(data: DataFrame, xcolumn, ycolumn, size_column=None, color_column=None, xmin=None, xmax=None, ymin=None, ymax=None, xticks=None, yticks=None, size=1, color=None, cmap='rainbow', colorbar=True, xlabel=None, ylabel=None, title=None, figsize=(9.8, 8), pad=1, pos=(0, 0), rowspan=1, colspan=1, file_name=None, file_dpi=300)[source]
Display a 2-dimensional scatter plot.
- Parameters:
data – A Pandas DataFrame
xcolumn – The column for the horizontal dimension.
ycolumn – The column for the vertical dimension.
size_column – A column for the marker size. (optional)
color_column – A column with values for the marker color. (optional)
xmin – The lower limit for displayed values in the horizontal dimension. (optional)
xmax – The upper limit for displayed values in the horizontal dimension. (optional)
ymin – The lower limit for displayed values in the vertical dimension. (optional)
ymax – The upper limit for displayed values in the vertical dimension. (optional)
xticks – A sequence of tick positions on the X axis. (optional)
yticks – A sequence of tick positions on the Y axis. (optional)
size – A factor to the marker size. (optional)
color – A color for the markers. (optional) Gets overridden by color_column.
cmap – A Matplotlib Colormap or the name of a color map. Is used in combination with color_column. (optional) See matplotlib.pyplot.scatter() for more info.
colorbar – A switch to control if a colorbar is shown. (optional)
xlabel – A label for the X axis. (optional)
ylabel – A label for Y axis. (optional)
title – A title for the plot. (optional)
figsize – The figure size in inches. (optional)
pad – Padding around the figure. (optional)
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.scatter_map(data: DataFrame, longitude_column='longitude', latitude_column='latitude', region=None, autofit=False, projection='merc', map_resolution='i', grid=(1, 2), map_style=None, map_style_attributes=None, size_column=None, size=1, size_mode=None, color_column=None, color='blue', cmap='YlGnBu', colorbar=True, title=None, figsize=(10, 10), pad=1, pos=(0, 0), rowspan=1, colspan=1, file_name=None, file_dpi=300)[source]
Displays a scatter plot on a geographical map.
- Parameters:
data – A Pandas DataFrame.
longitude_column – The column with the longitudes. (optional)
latitude_column – The column with the latitudes. (optional)
region – The geographic region to plot. (optional) A iterable with four elements: lower left corner latitude, lower left corner longitude, upper right corner latitude, and upper right corner longitude.
autofit – A switch to automatically zoom to a region, showing all markers. (optional)
grid – A pair of distances for grid lines (lat, lon). (optional)
projection – The named projection of the map. See https://matplotlib.org/basemap/users/mapsetup.html
map_style – The name of a style. (optional)
map_style_attributes – A dict with style attributes. (optional)
map_resolution – The resolution of geographical and political features on the map: crude c, low l, intermediate i, high h, or full f. (optional)
size_column – A column with marker sizes. (optional)
size – A factor to the marker size. (optional)
size_mode – The mode for applying the size: area or radius. (optional)
color_column – A column with values for the marker color. (optional)
color – A color for the markers. (optional) Gets overridden by color_column.
cmap – A Matplotlib Colormap or the name of a color map. Is used in combination with color_column. (optional) See matplotlib.pyplot.scatter() for more info.
colorbar – A switch to control if a colorbar is shown. (optional)
title – A title for the plot. (optional)
figsize – The figure size in inches. (optional)
pad – Padding around the figure. (optional)
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.scatter_matrix(data: DataFrame, columns=None, mins=None, maxs=None, bins=None, ticks=None, sample=None, random_state=None, key_column=None, color=None, subplot_size=2, pad=1, w_pad=1.0, h_pad=1.75, file_name=None, file_dpi=300)[source]
Plots a matrix of scatter plots and histograms for a number of columns from a Pandas DataFrame.
Warning: This function cannot be used between begin() and end() as part of another multiplot.
- Parameters:
data – A Pandas DataFrame.
columns – The columns to include into the matrix. (optional)
key_column – A column used to build groups. (optional)
color – A list or dict with colors for the groups. (optional)
mins – A dict, mapping column names to minimal values. (optional)
maxs – A dict, mapping column names to maximal values. (optional)
sample – A ratio between 0 and 1 to show a random subset in the scatter plots. (optional)
random_state – The initial random state for selecting a subset. (optional)
bins – A dict, mapping column names to bins. (optional)
ticks – A dict, mapping column names to ticks. (optional)
subplot_size – The edge length for the subplots. (optional)
pad – Padding around the figure. (optional)
w_pad – Horizontal space between subplots. (optional)
h_pad – Vertical space between subplots. (optional)
file_name – A path to a file to save the plot in. (optional)
file_dpi – A resolution to render the saved plot. (optional)
- mastersign.datascience.plot.set_figure_handler(handler)[source]
Set a handler, which is called after rendering every plot.
The specified handler must accept the following keyword arguments:
subplot
A boolean flag indicating that the figure is a subplotfig
The figure object of the plotax
The main axis or Nonetitle
A title for the main axis or Nonepad
A padding value for calling tight_layout() or Nonefile_name
The filename for the target image file or Nonefile_dpi
The dpi value for the target image file or None
- Parameters:
handler – The figure handler to use for future plots
- mastersign.datascience.plot.spec_col_file(filename)[source]
Specify an INI file with column names to be automatically used in plots. The column-label-pairs must be placed under the INI section [Columns].
- Parameters:
filename – A path to the INI file.
- mastersign.datascience.plot.spec_col_labels(**kwargs)[source]
Specify labels for column names to be automatically used in plots.
- Parameters:
kwargs – A map of column names and labels.
- mastersign.datascience.plot.subplot(pos=(0, 0), rowspan=1, colspan=1)[source]
Prepares a sub-plot inside the current figure between calls of begin() and end().
This method is useful, if a custom plot must be integrated into a multiplot created with mastersign.datasience.plot.
- Parameters:
pos – The position in the grid of a multiplot. (optional)
rowspan – The number of rows to span in the grid of a multiplot. (optional)
colspan – The number of columns to span in the grid of a multiplot. (optional)
- Returns:
A tuple with Matplotlib figure and axes:
(fig, ax)
.
- mastersign.datascience.plot.table(data: DataFrame, columns=None, labels=None, with_index=True, index_label=None, limit=None)[source]
Displays an HTML table with the given data. A subset of columns can be selected with columns. The labels in the header can be explicitly specified with labels.
Does not support multi-indexes.
Calls IPython.display.display() to present the HTML table.
- Parameters:
data – A Pandas DataFrame
columns – An iterable with column names. (optional)
labels – An iterable with column labels. (optional) Must be the same size as the columns.
with_index – A switch to include or exclude the index. (optional)
index_label – A string or an iterable with labels for the index. (optional)
limit – A maximum number of rows to display. (optional)
Plotting with Basemap
This module contains functionality used to plot on a map.
See e.g. mastersign.datascience.plot.scatter_map().
- mastersign.datascience.plot.basemap.base_map(region: Mapping[str, float], projection: str = 'cyl', epsg: int | None = None, grid: Tuple[float, float] = (30, 60), resolution: str = 'i', style_name: str | None = None, style_attributes: Mapping[str, Any] | None = None, ax=None) Basemap [source]
Creates a Basemap instance containing continents, coastlines, rivers and country borders.
- Parameters:
region (Mapping[str, float]) – A Basemap compatible structure defining a rectangular geographical region. (See lat_lon_region().)
projection –
A named projection from Basemap. E.g. cyl, robin, mill, ortho, merc, and a lot more.
See https://matplotlib.org/basemap/users/mapsetup.html for more details.
epsg (Optional[int]) –
An EPSG projection code as an alternative to the named projection types. E.g. EPSG_WGS84_GIS, EPSG_WGS84_GPS, or EPSG_ETRS89.
See http://spatialreference.org/ref/epsg/ for EPSG codes.
lat_0 (float) – The latitude facing the viewer for orthographic projections.
lon_0 (float) – The longitude facing the viewer for orthographic projections.
grid (Tuple[float, float]) – A tuple with latitude and longitude intervals for drawing a grid.
resolution (str) – The Basemap resolution level:
c
(crude),l
(low),i
(intermediate),h
(high), orf
(full).style_name (str) – The name of a style in map_styles.
style_attributes (Optional[Mapping[str, Any]]) – A dict like structure with overridings for the style.
ax – A mapplotlib Axes object.
- Returns:
The initialized Basemap instance.
- Return type:
mpl_toolkits.basemap.Basemap
- mastersign.datascience.plot.basemap.g2m(m: Basemap, coord: Tuple[float, float]) Tuple[float, float] [source]
Convert geographical coordinate into x-y-coordinates in the plotting space.
- Parameters:
m (mpl_toolkits.basemap.Basemap) – The Basemap instance to use for conversion.
coord (Tuple[float, float]) – A tuple with the latitude and longitude.
- Returns:
A tuple with the x and y coordinates in the plotting space.
- Return type:
Tuple[float, float]
- mastersign.datascience.plot.basemap.g2ms(m: Basemap, coords: Iterable[Tuple[float, float]]) List[Tuple[float, float]] [source]
Convert an iterable with geographical coordinates into a list of x-y-coordinates in the plotting space.
- Parameters:
m (mpl_toolkits.basemap.Basemap) – The Basemap instance to use for conversion.
coords (Iterable[Tuple[float, float]]) – An iterable with geographical coordinates (lat, lon).
- Returns:
A list with x-y-coordinates in the plotting space.
- Return type:
List[Tuple[float, float]]
- mastersign.datascience.plot.basemap.g2xys(m: Basemap, coords: Iterable[Tuple[float, float]]) Tuple[Sequence[float], Sequence[float]] [source]
Convert an iterable with geographical coordinates into two sequences with x- and y-coordinates in the plotting space.
Can be used to convert an iterable with geographic coordinates into the input for a line or scatter plot.
- Parameters:
m (mpl_toolkits.basemap.Basemap) – The Basemap instance to use for conversion.
coords (Iterable[Tuple[float, float]]) – An iterable with geographical coordinates (lat, lon).
- Returns:
Two lists with x- and y-coordinates in the plotting space.
- Return type:
Tuple[Sequence[float], Sequence[float]]
- mastersign.datascience.plot.basemap.lat_lon_region(lower_left_corner_latitude, lower_left_corner_longitude, upper_right_corner_latitude, upper_right_corner_longitude)[source]
Converts a geographical region with lower left corner and upper right corner into a Basemap compatible structure.
- Parameters:
lower_left_corner_latitude – The latitude of the lower left corner.
lower_left_corner_longitude – The longitude of the lower left corner.
upper_right_corner_latitude – The latitude of the lower left corner.
upper_right_corner_longitude – The longitude of the lower left corner.
- Returns:
A dict with the keys
llcrnrlat
,llcrnrlon
,urcrnrlat
, andurcrnrlon
.