sphinx_gmt.gmtplot


A directive for including a GMT plot in a Sphinx document.

Options

The gmtplot directive supports the following options:

show-code

Whether to show the source code. The default can be changed by the gmtplot_show_code variable in conf.py.

language

Specify the language of the source code: either “bash” or “python”.

caption

Caption of the rendered figure.

Additionally, this directive also supports options of the standard figure and literalinclude directives.

Configuration options

The following options can be set in conf.py and will apply globally:

gmtplot_show_code

Default value for the show-code option. Default is True.

gmtplot_basedir

Base directory, to which gmtplot file names are relative to. If None or empty, file names are relative to the directory where the file containing the directive is. However, if it is absolute (starting with /), it is relative to the top source directory. Default is None.

gmtplot_figure_align

The figure alignment. Default is "center".

gmtplot_gmt_config

A dict of GMT settings that are applied to all GMT scripts. Default is {"GMT_GRAPHICS_FORMAT": "ps"}.

Classes

GMTPlotDirective(name, arguments, options, ...)

The gmtplot directive implementation.

Functions

environ(env)

Temporarily set environment variables inside the context manager and fully restore previous environment afterwards.

eval_bash(code, code_dir, output_dir, ...[, ...])

Execute a multi-line block of bash code and copy the generated image files to specified output directory.

eval_python(code, code_dir, output_dir, ...)

Execute a multi-line block of Python code and copy the generated image files to specified output directory.

get_suffix_from_language(language)

Determine suffix from language.

guess_language(filename)

Guess language from suffix of the script.

render_figure(code, code_dir, language, ...)

Run a GMT code and save the images in output_dir with file names derived from output_base.

setup(app)

Add the gmtplot directive to the sphinx app.