1

I'm trying to scale a pgfplots that uses group plots but something is not working properly. This is the MWE:

\documentclass{article}
\usepackage[%
  total={6in,9in},%
  body={111.5mm,185.6mm},%
  head=10pt,
  centering,showframe,
]{geometry}
\usepackage{showframe}

\usepackage{pgfplots} \usepgfplotslibrary{groupplots, colorbrewer} \usepackage{tikzscale}

\begin{document} \includegraphics[width=1.\linewidth,axisratio=1]{group_plot.tikz} \input{group_plot.tikz} \end{document}

and the file group_plot.tikz is simply:

\begin{tikzpicture}[]

\begin{groupplot}[cycle list/Dark2, group style={group name=myplot, group size= 2 by 1, horizontal sep=0.5em}, every axis plot/.append style={line width=0.4mm, line join=round}, axis lines = middle, enlargelimits = true, x axis line style = {thick,-stealth}, y axis line style = {thick,-stealth}, legend style={font=\footnotesize, at={(0.61,0)}, anchor=south, draw=none, yshift=-23pt, fill=white, fill opacity=0.9, /tikz/every even column/.append style={column sep=0.2cm}}, legend columns=3, xmin=-1,xmax=1, ymin=-1,ymax=1., % every axis x label/.style={at={(current axis.east)}, yshift=3pt}, ]

\nextgroupplot[ cycle list name = Dark2, xlabel=$\xi$, ylabel={$\xi^i$}, xtick={-1,1}, ytick={1}, every axis y label/.style={at={(current axis.north)}, xshift=8pt,yshift=-2pt}, ] % use TeX as calculator: \addplot + [mark=none, domain=-1:1] {x}; \nextgroupplot[ cycle list name = Dark2, xlabel=$\xi$, ylabel={$L_i(\xi)$}, xtick={-1,1}, ytick={1}, every axis y label/.style={at={(current axis.north)}, xshift=15pt,yshift=-2pt}, ] % use TeX as calculator: \addplot + [mark=none, domain=-1:1] {x};
\end{groupplot} \draw[red] (current bounding box.south west) rectangle (current bounding box.north east);

\end{tikzpicture}

I get a result that doesn't make sense, with the error:

./group_plot.tikz:36: Package pgfplots Error: Error: Plot width `-6.1997pt' 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..

This is the result:

enter image description here

aaragon
  • 3,041

1 Answers1

0

I'm not entirely sure if this is the solution you are aiming. But I compile and got the same message with -6.1997pt etc. As I did just small changes following the linked answer cited in comments, I will only present these parts of the code, the rest remains intact.

Changes

Changes are:

  1. In your main file, \pgfplotsset{compat=1.10}. This is not mandatory, but results look nicer.
\usepackage{pgfplots}
\pgfplotsset{compat=1.10} % add
  1. In your group_plot.tikz add the following lines into \begin{groupplot}
\begin{groupplot}[
...
% add
  width=1/2*\textwidth-2.5cm,
  height=2.5cm
]

You edit the values in order to achieve the result you wish.

Those lines were the lines I noticed there weren't in your group define, but they were at the original one, besides, the log message wrote something about height and width, so that was my best guess.

  1. Not mandatory, but I reduced a little bit the size of the figure from 1 to 0.9 \linewidth in \includegraphics[width=0.9\linewidth,axisratio=1]{group_plot.tikz}.

Results

With \pgfplotsset{compat=1.10}.

enter image description here

Without \pgfplotsset{compat=1.10}.

enter image description here

FHZ
  • 3,939