TeX - LaTeX Asked on November 29, 2021
Situation:
I am trying to place one bigger pgfplot at the left side of a figure and four small plots (2×2) on the right half, like this:
|--------|----|----|
| | P2 | P3 |
| plot 1 |----|----|
| | P4 | P5 |
|--------|----|----|
For this I use two groupplots next to each other as shown here: Create groupplot 3 x 6. I scale them with tikzscale
, in order to fill the page and still maintain fontsize etc. Furthermore I need to plot one legend above all plots, as explained here: PGFplots – label each group plots
Problem:
Everything works fine as long as I do not use fillbetween
in the pgf plot. Here is a MWE that I compile twice with LuaLaTeX under Windows (MiKTeX, all packages are updated), the fillbetween
commands are commented so far:
documentclass{standalone}
usepackage{pgfplots}
usepgfplotslibrary{groupplots}
usepgfplotslibrary{fillbetween}
usetikzlibrary{calc}
usetikzlibrary{matrix}
usepackage{tikzscale}
pgfplotsset{compat=newest}
usepackage{filecontents}
begin{document}
begin{filecontents}{A.tikz}
begin{tikzpicture}
begin{groupplot}[
group style={
group name=left plot,
group size=1 by 1,
},
width=0.45*textwidth,
height=6cm,
xlabel={$x$},
ylabel={$y$},
scale only axis,
xmin=-0.028,
xmax=0.2222,
ymin=0.0,
ymax=0.6666,
xmajorgrids,
ymajorgrids,
axis x line=bottom,
axis y line=left,
]
nextgroupplot[]
addplot[name path=OneA,solid,color=gray, forget plot] coordinates { (-0.027,0.18) (0.0,0.0) (0.222,0.6666)};
addplot [name path=TwoA,solid,color=gray, forget plot] coordinates { (-0.027,0.18) (0.222,0.6666)};
%addplot[lightgray, forget plot] fill between[of = OneA and TwoA];
addplot coordinates { (0,0.05) (0.05,0.2) (0.15,0.55) (0.2,0.4) }; label{plot1}
addplot coordinates { (0,0.6) (0.05,0.1) (0.15,0.26) (0.2,0.44) }; label{plot2}
addplot coordinates { (0,0.1) (0.05,0.3) (0.15,0.33) (0.2,0.2) }; label{plot3}
addplot coordinates { (0,0.42) (0.05,0.41) (0.15,0.4) (0.2,0.39) }; label{plot4}
addplot coordinates { (0,0.6) (0.05,0.02) (0.15,0.61) (0.2,0.32) }; label{plot5}
end{groupplot}
begin{groupplot}[
group style={
group name=right plots,
group size=2 by 2,
horizontal sep = 1cm,
},
width=0.2*textwidth,
height=2.1cm,
scale only axis,
xmajorgrids,
ymajorgrids,
]
nextgroupplot[anchor=north west, at={($(left plot c1r1.north east) + (2cm,0)$)},
xmin=-0.015,
xmax=0.08,
ymin=0.0,
ymax=0.22,]
addplot[name path=OneB,solid,color=gray, forget plot] coordinates { (-0.027,0.18) (0.0,0.0) (0.222,0.6666)};
addplot [name path=TwoB,solid,color=gray, forget plot] coordinates { (-0.027,0.18) (0.222,0.6666)};
%addplot[lightgray, forget plot] fill between[of = OneB and TwoB];
addplot coordinates { (0,0.05) (0.05,0.2) (0.15,0.55) (0.2,0.4) };
nextgroupplot[]
addplot coordinates { (0,0.05) (0.05,0.2) (0.15,0.55) (0.2,0.4) };
nextgroupplot[]
addplot coordinates{ (0,0.05) (0.05,0.2) (0.15,0.55) (0.2,0.4) };
nextgroupplot[]
addplot coordinates { (0,0.05) (0.05,0.2) (0.15,0.55) (0.2,0.4) };
end{groupplot}
% legend
path (left plot c1r1.north west|-current bounding box.north)--coordinate(legendpos)(right plots c2r2.south east|-current bounding box.north);
matrix[
matrix of nodes,
anchor=south,
draw,
inner sep=0.2em,
draw
]at([yshift=1ex]legendpos)
{
ref{plot1}& $a=1$&[5pt]
ref{plot2}& $a=2$&[5pt]
ref{plot3}& Lit\
ref{plot4}& $a=3$&[5pt]
ref{plot5}& $a=4$\
};
end{tikzpicture}%
end{filecontents}
includegraphics[width=0.9textwidth]{A.tikz}
end{document}
It produces the (expected) output:
When I uncomment the first fillbetween
command in plot 1, font scaling crashes:
And things become really scary when I activate fillbetween
in the first of the four smaller plots (P2). This leads to wrong font scaling and wrong placement of the plot:
So I am not sure whether this is some kind of bug or whether I am just doing something wrong. Every help is greatly appreciated.
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP