0

I'm having trouble getting my plot to span the entire \textwidth. Here is an equivalent MWE of what I'm getting when I compile.enter image description here

Matplotlib code: (set_size is a function taken from here, but that doesn't really work either)

import matplotlib.pyplot as plt
import seaborn as sns

fmri = sns.load_dataset("fmri") fig, ax = plt.subplots(1, 4, figsize=(28,5))

fig, ax = plt.subplots(1, 4, figsize=set_size(465, subplots=(1,4)))

for i in range (4): sns.lineplot(x="timepoint", y="signal", err_style="bars", ci=68, ax=ax[i], data=fmri) plt.suptitle("Timepoint vs Signal") plt.savefig("timepoint_vs_signal.png")

Latex code:

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{subfig,graphicx}
\usepackage[lined, boxed, ruled, commentsnumbered]{algorithm2e}
\usepackage{mathtools,array,savesym}
\usepackage{amsfonts,amsthm, amsmath}
\usepackage{lipsum}  
% these are the packages I need, so I'm including them just in case it's necessary info

\begin{document}

\lipsum[1]

% \showthe\textwidth % = ~469pt

\begin{figure}[ht] \begin{center} \includegraphics[width=\textwidth]{timepoint_vs_signal.png} \end{center} \end{figure}

\end{document}

What am I missing?

  • Hi, welcome. Look at the PNG, there's a lot of whitespace in it. (Unrelated, but I'd recommend using PDF over PNG.) You can crop the image (or run pdfcrop on a PDF, if you generate that), but I guess modifying the subplots to fill the entire figure would be better. That, however, is a Python question, so really out of scope for this site. – Torbjørn T. Aug 26 '20 at 21:01
  • You can try adding fig.tight_layout() before saving the figure though. – Torbjørn T. Aug 26 '20 at 21:12
  • Hi. Thanks for the comments. A quick follow up question, in this case, \textwidth, \columnwidth and \paperwidth are all equivalent, right? – madman_with_a_box Aug 26 '20 at 21:38
  • Not \paperwidth, that I think is the full width of the paper, but the two others are the same in a one column document (https://tex.stackexchange.com/q/16942), equal to the width of the textblock. – Torbjørn T. Aug 26 '20 at 22:08

0 Answers0