gpxplotter.mplplotting
This module defines methods for plotting GPX data using matplotlib.
- gpxplotter.mplplotting._add_elapsed_labels(axi, data, which='x')[source]
Add nicer labels for time-difference.
Convert elapsed time in seconds to hours:minutes:seconds.
- Parameters:
axi (object like
matplotlib.axes.Axes
) – The axes to add ticks for.data (array_like) – The data we are updating.
which (string, optional) – Selects the axes (x or y) we are updating.
- gpxplotter.mplplotting._get_data(data, key)[source]
Attempt to read a key from a dictionary.
This method is here to give some more instructive error messages.
- Parameters:
data (dict) – The dictionary to read from.
key (string) – The key we attempt to read from the dictionary.
- Returns:
out (any) – The values returned by
data[key]
.
- gpxplotter.mplplotting._make_time_labels(delta_seconds, nlab=5)[source]
Make n time-formatted labels for data in seconds.
- gpxplotter.mplplotting._select_cmap(zdata, cmap_name)[source]
Select a colormap and determine the number of colors.
- Parameters:
zdata ; array_like – The data used for creating the color map.
cmap_name (string) – The name of the color map to use.
- Returns:
cmap (object like
matplotlib.colors.ListedColormap
) – The created color map.norm (object like
matplotlib.colors.Normalize
) – The created normalization for the data.
- gpxplotter.mplplotting._shift_elapsed_labels(axi, start_time, which='x')[source]
Shift elapsed labels with a given time origin.
Make a time difference start at a given time.
- Parameters:
axi (object like
matplotlib.axes.Axes
) – The axes to add ticks for.start_time (object like
datetime.datetime
) – The starting time to use for shifting.which (string, optional) – Selects the axes (x or y) we are updating.
- gpxplotter.mplplotting._update_limits(axi, data, which='x', factor=0.025)[source]
Update limits for axes (x or y).
This method will lengthen the given axes.
- Parameters:
axi (object like
matplotlib.axes.Axes
) – The axes to update for.data (array_like) – The data we are plotting on the given axes.
which (string, optional) – Determines if we are updating the x or y-axes.
factor (float, optional) – Half of the factor of the current length to add.
- gpxplotter.mplplotting._update_time_ticklabels(axi, xvar, yvar, xdata, ydata)[source]
Update time tick labels for time data.
- Parameters:
axi (object like
matplotlib.axes.Axes
) – The axes to add ticks for.xvar (string) – The variable used for the x-axis.
yvar (string) – The variable used for the y-axis.
xdata (array_like) – The data used for the x-axis.
ydata (array_like) – The data used for the y-axis.
- gpxplotter.mplplotting.add_regions(axi, xdata, ydata, regions, cut)[source]
Add heart rate patches to axis.
- Parameters:
axi (object like
matplotlib.axes.Axes
) – The axes to add regions to.xdata (array_like) – The x-values we are plotting for.
ydata (array_like) – The y-values we are plotting for.
regions (list of lists) – regions[i] defines a heart rate region as [start, stop, hr-region].
cut (integer, optional) – If given, the zones will be divided into smaller (inclusive) or larger than the given cut.
- gpxplotter.mplplotting.add_segmented_line(xdata, ydata, zdata, cmap_name='viridis')[source]
Create multicolored line.
Create a multicolored line, colored according to the provided
zdata
-values.- Parameters:
xdata (array_like) – x-positions to use.
ydata (array_like) – y-positions to use.
zdata (array_like) – Values to use for coloring the line segments.
cmap_name (string, optional) – Colormap to use for the colors.
- Returns:
out (object like
matplotlib.collections.LineCollection
) – The multicolored lines.
- gpxplotter.mplplotting.fix_elapsed_time(axi, var, data_axes, data_plot, which='x')[source]
For labels for time when elapsed time is used in plotting.
For coloring plots, the elapsed time data is used for making lines or polygons. This method will shift the labels back to the original variable.
- Parameters:
axi (object like
matplotlib.axes.Axes
) – The axes to add ticks for.var (string) – The variable used for the axis.
data_axes (array_like) – The data we are to use for making labels.
data_plot (array_like) – The actual data used for plotting.
which (string, optional) – Selects the axes (x or y) we are updating.
- gpxplotter.mplplotting.make_patches(xdata, ydata, zdata, cmap_name='viridis')[source]
Make some patches for multi-coloring the area under a curve.
- Parameters:
xdata (list or array_like) – The x positions for the curve.
ydata (list or array_like) – The y positions for the curve.
zdata (list or array_like) – A list of values associated with each point, used for coloring.
cmap_name (string, optional) – The name of the color map to use.
- Returns:
poly (object like
matplotlib.collections.PolyCollection
) – The polygons created here, with individual colors.cmap (object like
matplotlib.colors.ListedColormap
) – The created color map.norm (object like
matplotlib.colors.Normalize
) – The created normalization for the data.
- gpxplotter.mplplotting.plot_filled(track, data, xvar='distance', yvar='elevation', zvar='hr', cmap='viridis', cut=None, **kwargs)[source]
Plot a filled graph (line with colored area).
Plot a line and fill the area under it, given a specified variable.
- Parameters:
track (dict) – The track we are plotting for.
data (dict) – The segment we are plotting.
xvar (string, optional) – Selects the variable to use for the x-axes.
yvar (string, optional) – Selects the variable to use for the y-axes.
zvar (string, optional) – Selects the variable to use for coloring the area.
cmap (string, optional) – Color map to use for the coloring
cut (integer, optional) – If given and if we are plotting hr-regions, this will divide the coloring into two different groups (see .add_regions).
**kwargs (
matplotlib.lines.Line2D
properties, optional) – Extra properties for the plotting passed to theaxi.plot
method.
- Returns:
fig (object like
matplotlib.figure.Figure
) – The figure created here.ax1 (object like
matplotlib.axes.Axes
) – The axes to add ticks for.
- gpxplotter.mplplotting.plot_line(track, data, xvar='distance', yvar='elevation', zvar=None, cmap='viridis', **kwargs)[source]
Plot line data from a segment.
Plot a given segment from a track as a line. The line can be colored according to a given value.
- Parameters:
track (dict) – The track we are plotting for.
data (dict) – The segment we are plotting.
xvar (string, optional) – Selects the variable to use for the x-axes.
yvar (string, optional) – Selects the variable to use for the y-axes.
zvar (string, optional) – Selects the variable to use for coloring the line.
cmap (string, optional) – Color map to use for the coloring
**kwargs (
matplotlib.lines.Line2D
properties, optional) – Extra properties for the plotting passed to theaxi.plot
method.
- Returns:
fig (object like
matplotlib.figure.Figure
) – The figure created here.ax1 (object like
matplotlib.axes.Axes
) – The axes to add ticks for.
- gpxplotter.mplplotting.set_up_figure(track)[source]
Help with creating a figure.
This method will just create the figure and axis and set the title.
- Parameters:
track (dict) – The track we are creating a figure for.
- Returns:
fig (object like
matplotlib.figure.Figure
) – The figure created here.axi (object like
matplotlib.axes.Axes
) – The axis created here