pyexlatex.figure.models package

Submodules

pyexlatex.figure.models.figure module

class pyexlatex.figure.models.figure.Figure(subfigures, caption=None, label=None, centering=True, position_str=None, landscape=False, short_caption=None)[source]

Bases: pyexlatex.models.containeritem.ContainerItem, pyexlatex.models.item.Item

Used for creating latex figures from images. Currently the main usage is the Figure class created with the method Figure.from_dict_of_names_and_filepaths. Pass a dictionary where the keys are names for subfigures and the values are filepaths where the image for the subfigure is located.

__init__(subfigures, caption=None, label=None, centering=True, position_str=None, landscape=False, short_caption=None)[source]
as_document(landscape=False)[source]
classmethod from_dict_of_names_and_filepaths(filepath_name_dict, figure_name=None, position_str_name_dict=None, **kwargs)[source]

Create a Figure from a dictionary where keys are names of subfigures and values are file paths

Parameters
  • filepath_name_dict (dict) – dictionary where keys are names of subfigures and values are the filepaths to the images for those subfigures.

  • figure_name (Optional[str]) – name for overall figure

  • position_str_name_dict (Optional[dict]) – dictionary where keys are names of subfigures and values are the position strs for those figures, e.g. r’[t]{0.45linewidth}’

  • kwargs – kwargs for Figure

Returns

Figure

classmethod from_dict_of_names_and_plt_figures(plt_fig_name_dict, sources_outfolder, source_filetype='pdf', figure_name=None, position_str_name_dict=None, **kwargs)[source]

Create a Figure from a dictionary where keys are names of subfigures and values are matplotlib Figures or Axes

Parameters
  • plt_fig_name_dict (Dict[str, Union[ForwardRef, ForwardRef]]) – Key is display name in output figure, value is matplotlib axes or figure

  • sources_outfolder (str) – folder to output individual matplotlib figures

  • source_filetype (str) – Filetype for individual plt figures. The default is pdf. Use png or another image type if outputting complicated figures or performance may be affected when viewing the pdf.

  • figure_name (str) – name for overall figure

  • position_str_name_dict (dict) – dictionary where keys are names of subfigures and values are the position strs for those figures, e.g. r’[t]{0.45linewidth}’

  • kwargs – kwargs for Figure

Returns

Figure

name = 'figure'
to_graphic_list()[source]
Return type

List[Graphic]

to_pdf_and_move(as_document=True, outfolder=None, outname=None, landscape=False)[source]

pyexlatex.figure.models.graphic module

class pyexlatex.figure.models.graphic.Graphic(filepath, width=1.0, cache=True, options=None, overlay=None)[source]

Bases: pyexlatex.models.item.SimpleItem

Basic class for including graphics, just the image with no structure.

In most documents, a Figure would be used to give more structure to the graphic. This class will literally just include the image with no other structure. It is typically more useful in presentations where the structure is already being provided.

__init__(filepath, width=1.0, cache=True, options=None, overlay=None)[source]
Parameters
property filepath: str
Return type

str

property filepaths: List[str]
Return type

List[str]

name = 'includegraphics'
property options_str: Optional[str]
Return type

Optional[str]

property source_path: str
Return type

str

property width_str: str
Return type

str

pyexlatex.figure.models.inlinegraphic module

class pyexlatex.figure.models.inlinegraphic.InlineGraphic(filepath, width=1.0, cache=True, options=None, overlay=None)[source]

Bases: pyexlatex.models.item.MultiOptionSimpleItem, pyexlatex.figure.models.graphic.Graphic

A version of Graphic that is meant to be used within text. It centers the text vertically when the graphic is taller than the text.

__init__(filepath, width=1.0, cache=True, options=None, overlay=None)[source]
Parameters
name = 'vcenteredinclude'
options: tuple

pyexlatex.figure.models.subfigure module

class pyexlatex.figure.models.subfigure.Subfigure(filepath, caption=None, label=None, centering=True, position_str='[t]{0.45\\\\linewidth}', cache=True)[source]

Bases: pyexlatex.models.containeritem.ContainerItem, pyexlatex.models.item.Item

Used for more control over building figures

__init__(filepath, caption=None, label=None, centering=True, position_str='[t]{0.45\\\\linewidth}', cache=True)[source]
name = 'subfigure'
pyexlatex.figure.models.subfigure.anchor_and_width_from_position_str(position)[source]
Return type

Tuple[str, str]