How to determine the correct font size of texts in my figure

Viewed 36

I am generating figures for a scientific paper, but I have some issues to know what size my figure should have to obtain the correct font size when my figure will be put in my paper.

Currently, to be sure all my figures have the same shape when generated, I use the following function which only allows two size of figures: Rectangle and Square:

    def create_figure(shape: Union[tuple, FigureShape] = FigureShape.RECTANGLE) -> Tuple[plt.Figure, plt.Axes]:
        """
        Create a basic figure with a normalized shape
        This is really useful for all application which need figure
        :param shape:
        :return: A tuple containing the figure and the main axis used by the figure
        """

        plt.style.use(['science', 'ieee', 'vibrant'])

        F: plt.Figure
        if shape == FigureShape.SQUARE:
            F = plt.figure(figsize=(3, 3))
        elif shape == FigureShape.RECTANGLE:
            F = plt.figure(figsize=(2.6 * (1 + sqrt(5) / 2), 2.6))
        else:
            raise Exception(f'Unknown shape {shape}')

        ax: plt.Axes = F.add_subplot(111)
        ax.set_axisbelow(True)
        ax.grid(
            color='#666666',
            linestyle='--',
            linewidth=0.3,
            visible=True
        )

        return F, ax

(Note that the content of figsize have been determined randomly for now. I just wanted good looking square and rectangle shapes.)

But there is my issue: my final figures will be presented on a double column paper, and I would like that, when my figure size is reduced to fill one column in width (3.5 inches, see below), the font size of axis labels and legend will be exactly 10px (i.e. the same size as my main text).

According to IEEE recommendations for authors, this is the width images should have depending of the number of column they fill:

  • One column width: 3.5 inches, 88.9 millimeters, or 21 picas
  • Two columns width: 7.16 inches, 182 millimeters, or 43 picas

I am using Latex to write my paper and PdfLatex for the compilation.

1 Answers

I always run the following code (below) in LaTeX, which tells me the dimensions of a text area and column width. Then, in matplotlib I can set the proper width of my images to have a proper fit in a column or in a page. The screenshot is from IEEEtran document class.

enter image description here

\documentclass{IEEEtran}  % probably already in your document
% \usepackage{xfp}  % Required before 2022/01/06

%%% BEGIN Snippet
\begin{document}
\noindent%
\begin{table}[tbh]
  %%5 Display basic dimensions
  \begin{tabular}{lrr}
    Column width:
    & \fpeval{round(\the\columnwidth,1)} pt
    & \fpeval{round(\the\columnwidth*25.4/72.27,1)} mm \\
    Two column width:
    & \fpeval{round(\the\textwidth,1)} pt
    & \fpeval{round(\the\textwidth*25.4/72.27,1)} mm \\[6pt]
    %%% This only make sense in twocolumn documents
    Column sep$^{1}$.:
    & \fpeval{round(\the\columnsep,1)} pt
    & \fpeval{round(\the\columnsep*25.4/72.27,1)} mm \\
    \multicolumn{3}{l}{{$^{1}$ \scriptsize Valid only in two column documentclass:\par}}
  \end{tabular}
\end{table}
%%% END Snippet

\end{document}

EDIT.
Ignore me if you know that, however for clarification if you want dimensions in inches, just remove the factor: 25.4

Also for clarification, it is the snippet which should be copied into a document right after \begin{document} because \documentclass is already there. In case the snippet doesn't work, have the extra package \usepackage{xfp} loaded, which adds \fpeval{}. The latter is added in new LaTeX starting from 2022/01/06.

Related