I am using matplotlib and exporting my plots as pfg so I can keep math notation in latex.

I am using elsarticle. Things were working quite well until I switched the template to two columns. In this case the plot is too big and goes beyond the column.

This what I have at the moment:

    \caption{This is my plot}

how can I set width so it works well in both single and double column?

  • Does setting \pgfplotsset{width=0.9\linewidth} in the preamble of your document help? – user121799 May 1 at 5:53

You can either set the width manually relative to the type width with a simple scale box and adjust according to a prefered size

    \scalebox{0.15\typewidth}{\import{./}{example.pgf}} \label{fig:myplot2}
This is simple answer (scale box width manually)
     \caption{This is my plot TWO}

OR set it relative to self adjust to column width

\begin{figure}[htb] % loading oversise as 98% of column width
\resizebox{0.98\columnwidth}{!}{\input{example.pgf}} \label{fig:myplot3} 
This is better answer (resize box width automagically to suit column)
     \caption{This is my plot THREE}
\end {figure}  

enter image description here

  • I would need to try.. but by resizing, will all the text (legends, etc.) will be resized too?. Any way to avoid that? I think I will need to create the charts with the correct double column width – Juan Leni Apr 1 at 4:18
  • Scaling will usually affect fonts etc the method to avoid that is either to import some components separately or use a system such as matplotlib 2 tikz as described here tex.stackexchange.com/questions/165042/… where the full width or half width graphic have the same size text – user170109 Apr 1 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.