Plotting

This page lists the plotting methods provided as part of nevis.

Alphabetical list:

nevis.plot(boundaries=None, labels=None, trajectory=None, points=None, scale_bar=True, big_grid=False, small_grid=False, zoom=0.037037037037037035, headless=False, verbose=False)[source]

Creates a plot of the 2D elevation data in heights.

By default, this method uses pyplot to create the figure, which can have the side-effect of instantiating a back-end for maptlotlib. Alternatively, the plot can be created in “headless” mode, by setting headless=True.

Arguments:

boundaries

An optional tuple (xmin, xmax, ymin, ymax) defining the boundaries (in meters) of the plotted region.

labels

An optional dictionary mapping string labels to points (tuples in meters or Coords objects) that will be plotted on the map (if within the boundaries).

trajectory

An optional array of shape (n_points, 2) indicating the trajectory followed to get to Ben Nevis (points specified in meters).

points

An optional array of shape (n_points, 2) indicating points on the map (points specified in meters).

scale_bar

Set to False to disable the scale bar.

big_grid

Show the 2-letter grid squares (100km by 100km).

small_grid

Show the 2-letter 2-number grid squares (10km by 10km)

zoom

Adjust plot size by interpolating (zoom > 1) or downsampling ( zoom < 1).

To downsample by e.g. a factor 10, set zoom = 1 / 10. To interpolate and show e.g. 3x3 pixels per data point, set zoom = 3. Interpolation is performed using matplotlib’s “bilinear interpolation”.

The default value is 1 / 27, which creates a reasonably sized plot for the full GB data set.

headless

Set to True to create the figure without using pyplot.

verbose

Set to True to print updates to stdout while plotting.

Returns a tuple (fig, ax, heights, g) where fig is the created figure, ax is the axes the image is plotted on, and heights is the (possibly downsampled) numpy array. The final entry g is a function that converts coordinates in meters to coordinates on the map axes.

nevis.plot_line(f, point_1, point_2, label_1='Point 1', label_2='Point 2', padding=0.25, evaluations=400, figsize=(8, 5), headless=False, verbose=False)[source]

Draws a line between two points and evaluates a function along it.

Note that this method assumes you will want to write the figure to disk with fig.savefig(). If you want to display it using pyplot, set headless=False.

Arguments:

f

A function f(x, y) -> z, or a sequence of multiple such functions.

point_1

The first point as a set of Coords or a numpy array in meters.

point_2

The second point.

label_1, label_2

Optional labels for the points.

padding

The amount of padding shown to the left and right of the points, as a fraction of the total line length (e.g. padding=0.25 extends the line on either side by 25% of the distance between the two points).

evaluations

The number of evaluations of f to plot.

figsize

The default figure size

headless

Set to True to create the figure without using pyplot.

verbose

Set to True to print updates to stdout while plotting.

Returns a tuple (fig, ax, p1, p2) where fig is the generated figure, ax is the axes object within that figure, and p1 and p2 are the extremities of the line (points 1 and 2 plus padding) (as Coords).

nevis.save_plot(path, fig, heights=None, verbose=False)[source]

Stores the given figure using fig.savefig(path).

If heights is given and PIL (pillow) is installed it will also check that the image dimensions (in pixels) equal the size of heights.