I have a figure environment with which I depict two pgfplots axis environments next to each other. I want to scale the figure such that it uses the full \textwidth. I attempt to do so by means of the tikzscale package. I however, get the error
! Package pgfplots Error: Error: Plot width `-144.19234pt' is too small. This cannot be implemented while maintaining constant size for labels. Sorry, label sizes are only approximate. You will need to adjust your width..
while there is plenty of room to scale the figure.
The minimum working example is as follows.
\documentclass{article}
\usepackage{currfile}
\usepackage{float} % Improved interface for floating objects.
\usepackage{lipsum} % For test purposes.
\usepackage{pgfplots}
\usepackage{showframe}
\usepackage{tikzscale}
% TikZ libraries.
\usetikzlibrary{calc}
\usetikzlibrary{external}
\tikzset{external/system call={lualatex -shell-escape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}}
\tikzexternalize
\usetikzlibrary{plotmarks}
\begin{document}
\lipsum[1]
\begin{figure}[H]
\begin{center}
\tikzset{external/remake next}
\tikzsetnextfilename{\currfiledir tikzpicture}
\includegraphics[width=\textwidth]{\currfiledir tikzpicture.tikz}
\end{center}
\caption{Test caption.}
\end{figure}
\lipsum[2]
\end{document}
The content of tikzpicture.tikz is represented by
\begin{tikzpicture}
\begin{loglogaxis}
[
name=plot_left,
xlabel=$x$,
ylabel=$y$
]
\addplot {x};
\end{loglogaxis}
\begin{loglogaxis}
[
name=plot_right,
at={($(plot_left.outer east)+(5mm,0)$)},
anchor=outer west,
legend style=
{
at={(1,1)},
anchor=north west,
draw=none,
fill=none
},
legend cell align=left,
xlabel=$x$,
ylabel=$y$
]
\addplot {x};
\legend
{
$l_1$
}
\end{loglogaxis}
\draw[dashed,line width=0pt] (plot_left.outer south west) rectangle (plot_left.outer north east);
\draw[dashed,line width=0pt] (plot_right.outer south west) rectangle (plot_right.outer north east);
\end{tikzpicture}
How do I resolve this error?
\matrix. But besides that, the problem is the same: scaling a figure to the\texwidth. – Adriaan Oct 02 '15 at 14:46tikzscaleand tell him of this, perhaps he can find a fix for the package. – Torbjørn T. Oct 03 '15 at 15:23I've found out, that using
– Nivek Aug 24 '21 at 18:55at=(plot2.right of south east),andanchor=left of south west,reduce the error probability. Furthermore scaling theheight(if necessary in combination withaxisratio) instead of thewidthreduces the error as well. But this way you cannot scale figures to the width of the line etc. Any help appreciated!