figsize¶
-
texfigure.
figsize
(pytex, scale=None, height_ratio=None, figure_width_context='figurewidth')[source]¶ A helper for calculating figure sizes based upon latex page widths. This uses the
pythontexcontext
to access the figurewith variable from LaTeX, this function then returns a matplotlibfigwidth
tuple based on the scale and height_ratio parameters.Parameters: pytex : PythonTeX Utilites Class
The PythonTeX helper class instance from the LaTeX document.
scale : float
The scale of the figure width in comparison to the textwidth, i.e. 1 = 100%.
height_ration : float
The ratio of the height to the width. Default is the golden ratio. (~0.61), 1.0 would lead to a square figure.
figure_width_context :
string
The pytex context variable to use to generate the figure width.
Returns: fig_size : tuple
The
(width, height)
tuple of the figure size in inches for mpl.Examples
% Give PythonTeX the Textwidth \setpythontexcontext{figurewidth=\the\textwidth} \begin{document} \begin{pycode} plt.figure(figsize=figsize(pytex)) ... \end{pycode}