Figure

class texfigure.Figure(file_name, reference=None)[source]

Bases: object

A class for holding a figure file, that knows how to represent itself as a latex environment.

Parameters:

file_name : str

The full path of the figure file.

reference : str

A reference label for this figure, used as default values for caption and label.

Examples

\begin{pycode}
import matplotlib.pyplot as plt

fig = plt.figure()
plt.plot([1,2], [3,4], 'o')

myfig = texfigure.Figure(fig, 'myfig')
\end{pycode}

\py|myfig|

Attributes

fname (str) The base name of the full file path
base_dir (str) The directory containing the figure file
caption (str) The caption to use when representing the figure. (Default Figure reference)
label (str) The latex label assigned to the figure envrionment, will bre prefixed with 'fig. (Default fig:reference)
placement (str) The figure envrionment placement value. (Default h)
figure_env_name (str) The string used for the figure environment i.e. \begin{figure}. Useful for changing to figure* etc. (Default figure)
figure_width (str) The latex figure width, not used for pgf files. (Default 0.95\columnwidth)
subfig_width (str) LaTeX figure width for when the figure is included in a subfigure. (Default 0.45\columnwidth)
subfig_placement (str) The subfigure environment placement. (Default b)
extension_mapping (dict) A mapping of file extensions to methods to return LaTeX includes for the file type.
fig_str (str) The LaTeX template for representing this Figure as a figure environment.
subfig_str (str) The LaTeX template for representing this Figure as a subfigure.

Attributes Summary

extension File extension of fname.
fig_str
subfig_str

Methods Summary

get_pgf_include() Return the import statement for this Figure as a pgf file.close.
get_standard_include() Return the includegraphics command for most other file types.
repr_figure() Return a string LaTeX figure environment for this Figure
repr_subfigure() Return a string subfigure environment for this Figure

Attributes Documentation

extension

File extension of fname.

fig_str = '\n\\begin{{{figure_env_name}}}[{placement}]\n \\centering\n {myfig}\n \\caption{{{caption}}}\n \\label{{{label}}}\n\\end{{{figure_env_name}}}\n'
subfig_str = '\n \\begin{{subfigure}}[{placement}]{{{width}}}\n {myfig}\n \\caption{{{caption}}}\n \\label{{{label}}}\n \\end{{subfigure}}'

Methods Documentation

get_pgf_include()[source]

Return the import statement for this Figure as a pgf file.close.

get_standard_include()[source]

Return the includegraphics command for most other file types.

repr_figure()[source]

Return a string LaTeX figure environment for this Figure

repr_subfigure()[source]

Return a string subfigure environment for this Figure