Skip to content

Tikzscale does not work with groupplots larger than 1x2 #5

Description

@anates

When trying to combine a groupplots-figure with tikzscale scaling fails for group plots larger than 1x2. Compiling

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{external}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usepackage{layouts}
\pgfplotsset{compat=1.17}
\usepackage{siunitx}
\usepackage{tikzscale}
\tikzexternalize[prefix=tikz-cache/]
\tikzset{external/force remake}

\pgfplotsset{compat=1.17}
\pgfplotsset{every axis/.append style={
		label style={font=\footnotesize\bfseries},
		tick label style={font=\footnotesize},
		legend style={font=\footnotesize}
	},
	y axis/.append style={align=center}}
\tikzset{Line Label/.style={font=\footnotesize,scale=2}}
%\sisetup{detect-weight=true, detect-family=true}
\newcommand{\figurefontsize}{\footnotesize}

\begin{document}

	\begin{figure}[htpb]
		\centering
        \includegraphics[width=0.4\linewidth, height=0.5\linewidth]{stacked_test_simple_dual.tikz}
        \caption{This is a test}
	\end{figure}
\end{document}

with the tikz-figure stacked_test_simple_dual.tikz, defined as

\usepgfplotslibrary{groupplots}
\begin{tikzpicture}
	
	\definecolor{color0}{rgb}{0.12156862745098,0.466666666666667,0.705882352941177}
	\definecolor{color1}{rgb}{1,0.498039215686275,0.0549019607843137}
	
	\begin{groupplot}[
		group style={
			% set how the plots should be organized
			group size=1 by 2,
			% only show ticklabels and axis labels on the bottom
			x descriptions at=edge bottom,
			% set the `vertical sep' to zero
			vertical sep=0pt,
		},
		]
		% start the first plot
		\nextgroupplot[
		tick align=outside,
		tick pos=left,
		x grid style={white!69.0196078431373!black},
		xmajorgrids,
		xmin=1, xmax=5,
		xtick style={color=black},
		y grid style={white!69.0196078431373!black},
		y label style={color=color0},
		yticklabel style={color=color0},
		xmajorticks=false,
		%ylabel={Plot 1},
		ymajorgrids,
		ymin=0, ymax = 26,
		ytick style={color=black}
		]
		\addplot [line width=1pt, color0]
		table {%
			1 1
			2 4
			3 9
			4 16
			5 25
		};
		\nextgroupplot[tick align=outside,
		tick pos=left,
		x grid style={white!69.0196078431373!black},
		xlabel={X data},
		xmajorgrids,
		xmin=1, xmax=5,
		xtick style={color=black},
		y grid style={white!69.0196078431373!black},
		ylabel style={color=color0},
		%ylabel={Plot 3},
		ymajorgrids,
		ymin = 0, ymax = 6,
		ytick style={color=black},
		yticklabel style={color=color0}
		]
		\addplot [semithick, color0, mark=square*, mark size=2, mark options={solid}, only marks]
		table {%
			1 1
			2 2
			3 3
			4 4
			5 5
		};
	\end{groupplot}
\end{tikzpicture}

works fine, but when replacing it with stacked_test_simple_triple.tikz, defined as

\usepgfplotslibrary{groupplots}
\begin{tikzpicture}
	
	\definecolor{color0}{rgb}{0.12156862745098,0.466666666666667,0.705882352941177}
	\definecolor{color1}{rgb}{1,0.498039215686275,0.0549019607843137}
	
	\begin{groupplot}[
		group style={
			% set how the plots should be organized
			group size=1 by 3,
			% only show ticklabels and axis labels on the bottom
			x descriptions at=edge bottom,
			% set the `vertical sep' to zero
			vertical sep=0pt,
		},
		]
		% start the first plot
		\nextgroupplot[
		tick align=outside,
		tick pos=left,
		x grid style={white!69.0196078431373!black},
		xmajorgrids,
		xmin=1, xmax=5,
		xtick style={color=black},
		y grid style={white!69.0196078431373!black},
		y label style={color=color0},
		yticklabel style={color=color0},
		xmajorticks=false,
		%ylabel={Plot 1},
		ymajorgrids,
		ymin=0, ymax = 26,
		ytick style={color=black}
		]
		\addplot [line width=1pt, color0]
		table {%
			1 1
			2 4
			3 9
			4 16
			5 25
		};
		\nextgroupplot[tick align=outside,
		tick pos=left,
		x grid style={white!69.0196078431373!black},
		xmajorgrids,
		xmin=1, xmax=5,
		xtick style={color=black},
		y grid style={white!69.0196078431373!black},
		ylabel style={color=color0},
		%ylabel={Plot 3},
		ymajorgrids,
		ymin = 0, ymax = 6,
		ytick style={color=black},
		yticklabel style={color=color0}
		]
		\addplot [semithick, color0, mark=square*, mark size=2, mark options={solid}, only marks]
		table {%
			1 1
			2 2
			3 3
			4 4
			5 5
		};
		\nextgroupplot[tick align=outside,
		tick pos=left,
		x grid style={white!69.0196078431373!black},
		xlabel={X data},
		xmajorgrids,
		xmin=1, xmax=5,
		xtick style={color=black},
		y grid style={white!69.0196078431373!black},
		ylabel style={color=color0},
		%ylabel={Plot 3},
		ymajorgrids,
		ymin = 0, ymax = 6,
		ytick style={color=black},
		yticklabel style={color=color0}
		]
		\addplot [semithick, color0, mark=square*, mark size=2, mark options={solid}, only marks]
		table {%
			1 1
			2 2
			3 3
			4 4
			5 5
		};
	\end{groupplot}
\end{tikzpicture}

it fails with

! Package pgfplots Error: Error: Plot height `-66.36208pt' is too small. This c
annot be implemented while maintaining constant size for labels. Sorry, label s
izes are only approximate. You will need to adjust your height..

Are there possible solutions for that issue?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions