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 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_path
data_dir
Data directory for files tracked with this manager. fig_dir
Figure directory for figures tracked with this manager. number
python_dir
Python 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/Data
will be used, if data_dir is set to astr
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 astr
then 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/Python
will be used, if python_dir is set to astr
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 filename of a figure that has already been saved
Parameters: ref :
str
The Figure reference
Returns: fname :
str
The filename
-
get_multifigure
(nrows, ncols, refs, reference='')[source]¶ Return a
texfigure.MultiFigure
object made up of a set of figure references stored in thisManager
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 currentpyplot
figure is to be used andgcf
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
-