Manager¶
-
class
texfigure.Manager(pytex, base_path, number=1, python_dir=True, data_dir=True, fig_dir=True)[source]¶ Bases:
objectA class holding information about different figures and data.
Parameters: pytex :
PythonTeXUtilsinstance.The pytex object from the PythonTeX session.
number :
intNumerical index for this chapter.
base_path :
strPath to the base directory for all files for this manager.
Path to a directory containing Python code to be added to the Python path.
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
chapter_pathdata_dirData directory for files tracked with this manager. fig_dirFigure directory for figures tracked with this manager. numberpython_dirPython directory for custom python code, this directory will be added to your Python Path. Methods Summary
Attributes Documentation
-
chapter_path¶
-
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/Datawill be used, if data_dir is set to astrthen 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/Figswill be used, if fig_dir is set to astrthen that dir will be used.
-
number¶
-
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/Pythonwill be used, if python_dir is set to astrthen 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 :
strThe latex reference for this figure (excluding ‘fig:’)
Fig :
texfigure.FigureThe
Figureobject 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 :
strThe filename in the data directory
-
get_figure(ref)[source]¶ Get the filename of a figure that has already been saved
Parameters: ref :
strThe Figure reference
Returns: fname :
strThe filename
-
get_multifigure(nrows, ncols, refs, reference='')[source]¶ Return a
texfigure.MultiFigureobject made up of a set of figure references stored in thisManagerinstance.Parameters: nrows :
intNumber of rows for the MultiFigure.
ncols :
intNumber of columns for the MultiFigure.
refs :
listA list of figure references no more than nrows * ncols long.
reference :
strThe reference for the
texfigure.MultiFigureobject.Returns: multfigure :
texfigure.MultiFigureThe 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 :
strThe latex reference for this figure (excluding ‘fig:’)
fname :
strOverwrite the default file name template with this name.
Returns: fname :
strThe 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 :
strA
strto 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_functionsdictionary. If None it will be assumed that the currentpyplotfigure is to be used andgcfwill be called.fname :
strThe file name to be used, not including the extension or the path.
fext :
strThe file extension to be used to save the file.
kwargs :
dictOther keyword arguments are passed onto the save figure function.
Returns: Fig :
texfigure.Figure
-