Manager

class texfigure.Manager(pytex, base_path, number=1, python_dir=True, data_dir=True, fig_dir=True)[source]

Bases: object

A class holding information about different figures and data.

Parameters:

pytex : PythonTeXUtils instance.

The pytex object from the PythonTeX session.

number : int

Numerical index for this chapter.

base_path : str

Path in which Data, Figs and Python directories will be created to hold files related to this manager. If python_dir, data_dir or figure_dir are specified then they will override this setting.

python_dir : bool or str

Path to a directory containing Python code to be added to the Python path. Overrides base_path/Python.

data_dir : bool or str

Path to a directory containing data files which can be accessed through the manager. Overrides base_path/Data

figure_dir : bool or str

Path to a directory containing generated figures. Overrides base_path/Figs

Attributes

savefig_functions (dict) A mapping between figure types and functions to save them to a given filename. Functions in the mapping must accept two arguments, the figure object and a filename, the function must return the filename as saved to disk.

Attributes Summary

data_dir Data directory for files tracked with this manager.
fig_dir Figure directory for figures tracked with this manager.
number A Number indicating the position of this manager in a series of managers, i.e.
python_dir Python directory for custom python code, this directory will be added to your Python Path.

Methods Summary

add_figure(ref, Fig) Add the figure to the tracked files and increment the figure count.
data_file(file_name) Get the full path of a data file in this chapters data directory, add it to the pytex tracked files.
get_figure(ref) Get the Figure object corresponding to the given reference.
get_multifigure(nrows, ncols, refs[, reference]) Return a texfigure.MultiFigure object made up of a set of figure references stored in this Manager instance.
make_figure_filename(ref[, fname, fext, ...]) Return the standard template figure name with number.
save_figure(ref[, fig, fname, fext]) Save a figure to a file, and track it using this manager object.

Attributes Documentation

data_dir

Data directory for files tracked with this manager.

If data_dir is set to False no directory will be used, if set to True the default directory of manager.base_path/Data will be used, if data_dir is set to a str then that dir will be used.

fig_dir

Figure directory for figures tracked with this manager.

If fig_dir is set to False no directory will be used, if set to True the default directory of manager.base_path/Figs will be used, if fig_dir is set to a str then that dir will be used.

number

A Number indicating the position of this manager in a series of managers, i.e. chapters in a thesis.

python_dir

Python directory for custom python code, this directory will be added to your Python Path.

If python_dir is set to False no directory will be used, if set to True the default directory of manager.base_path/Python will be used, if python_dir is set to a str then that dir will be used.

Notes

If this attribute is changed, the old directory will not be removed from the python path.

Methods Documentation

add_figure(ref, Fig)[source]

Add the figure to the tracked files and increment the figure count.

Parameters:

ref : str

The latex reference for this figure (excluding ‘fig:’)

Fig : texfigure.Figure

The Figure object to add to the manager.

data_file(file_name)[source]

Get the full path of a data file in this chapters data directory, add it to the pytex tracked files.

Parameters:

file_name : str

The filename in the data directory

get_figure(ref)[source]

Get the Figure object corresponding to the given reference.

Parameters:

ref : str

The Figure reference

Returns:

Figure : texfigure.Figure

The Figure object.

get_multifigure(nrows, ncols, refs, reference='')[source]

Return a texfigure.MultiFigure object made up of a set of figure references stored in this Manager instance.

Parameters:

nrows : int

Number of rows for the MultiFigure.

ncols : int

Number of columns for the MultiFigure.

refs : list

A list of figure references no more than nrows * ncols long.

reference : str

The reference for the texfigure.MultiFigure object.

Returns:

multfigure : texfigure.MultiFigure

The initilised and populated multifigure object.

make_figure_filename(ref, fname=None, fext='', fullpath=False)[source]

Return the standard template figure name with number.

Parameters:

ref : str

The latex reference for this figure (excluding ‘fig:’)

fname : str

Overwrite the default file name template with this name.

Returns:

fname : str

The file name

save_figure(ref, fig=None, fname=None, fext='.pdf', **kwargs)[source]

Save a figure to a file, and track it using this manager object.

Parameters:

ref : str

A str to use as a key inside this manager, and to add to the filename and to use a the latex reference.

fig : object

A figure object of a type that has an entry in the savefig_functions dictionary. If None it will be assumed that the current pyplot figure is to be used and gcf will be called.

fname : str

The file name to be used, not including the extension or the path.

fext : str

The file extension to be used to save the file.

kwargs : dict

Other keyword arguments are passed onto the save figure function.

Returns:

Fig : texfigure.Figure

The Figure object added to this Manager.