pylatex.figure¶
This module implements the class that deals with graphics.
-
class
Figure
(*, position=None, **kwargs)[source]¶ Bases:
pylatex.base_classes.float.Float
A class that represents a Figure environment.
Parameters: position (str) – Define the positioning of a floating environment, for instance 'h'
. See the references for more information.References
-
add_image
(filename, *, width=NoEscape(0.8\textwidth), placement=NoEscape(\centering))[source]¶ Add an image to the figure.
Parameters:
-
add_plot
(*args, extension='pdf', **kwargs)[source]¶ Add the current Matplotlib plot to the figure.
The plot that gets added is the one that would normally be shown when using
plt.show()
.Parameters: - args – Arguments passed to plt.savefig for displaying the plot.
- extension (str) – extension of image file indicating figure file type
- kwargs – Keyword arguments passed to plt.savefig for displaying the plot. In
case these contain
width
orplacement
, they will be used for the same purpose as in the add_image command. Namely the width and placement of the generated plot in the LaTeX document.
Add a caption to the float.
Parameters: caption (str) – The text of the caption.
-
omit_if_empty
= False¶
-
-
class
SubFigure
(width=NoEscape(0.45linewidth), **kwargs)[source]¶ Bases:
pylatex.figure.Figure
A class that represents a subfigure from the subcaption package.
Parameters: width (str) – Width of the subfigure itself. It needs a width because it is inside another figure. -
separate_paragraph
= False[source]¶ By default a subfigure is not on its own paragraph since that looks weird inside another figure.
-
add_image
(filename, *, width=NoEscape(\linewidth), placement=None)[source]¶ Add an image to the subfigure.
Parameters:
Add a caption to the float.
Parameters: caption (str) – The text of the caption.
-
add_plot
(*args, extension='pdf', **kwargs)[source]¶ Add the current Matplotlib plot to the figure.
The plot that gets added is the one that would normally be shown when using
plt.show()
.Parameters: - args – Arguments passed to plt.savefig for displaying the plot.
- extension (str) – extension of image file indicating figure file type
- kwargs – Keyword arguments passed to plt.savefig for displaying the plot. In
case these contain
width
orplacement
, they will be used for the same purpose as in the add_image command. Namely the width and placement of the generated plot in the LaTeX document.
-
omit_if_empty
= False¶
-
-
class
StandAloneGraphic
(filename, image_options=NoEscape(width=0.8textwidth), extra_arguments=None)[source]¶ Bases:
pylatex.base_classes.command.UnsafeCommand
A class representing a stand alone image.
Parameters: