我正在处理以下 MWE:
\documentclass[dvipsnames, aspectratio=169, 9pt]{beamer}
\usetheme{metropolis}
\usepackage{appendixnumberbeamer}
\usepackage{FiraSans}
\usepackage{booktabs}
\usefonttheme[onlymath]{serif}
\usepackage[scale=2]{ccicons}
\usepackage[export]{adjustbox}
%\usepackage[dvipsnames]{xcolor} %color extension
\usepackage{graphicx}
\usepackage{pgf,pgfplots,pgfplotstable}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{colormaps}
\usepgfplotslibrary{groupplots}
\usetikzlibrary{arrows.meta}
\usepgfplotslibrary{dateplot}
\usepackage{tabularx}
\usepackage[most]{tcolorbox}
\usepackage{xspace}
\newcommand{\themename}{\textbf{\textsc{metropolis}}\xspace}
\usepackage[font=footnotesize]{caption}
\begin{filecontents*}{data1.dat}
t1 a1 t2 a2 t3 a3
0.142 1.000 0.154 1.000 0.139 0.995
0.284 1.000 0.308 1.000 0.279 0.990
0.426 1.000 0.461 1.000 0.418 0.989
0.569 1.000 0.615 1.000 0.558 0.989
0.711 1.000 0.769 1.000 0.697 0.989
0.853 1.000 0.923 1.000 0.836 0.989
0.995 1.000 1.077 1.000 0.976 0.989
1.137 1.000 1.230 1.000 1.115 0.989
1.279 1.000 1.384 1.000 1.255 0.989
1.422 0.995 1.538 1.000 1.394 0.986
1.564 0.990 1.692 1.000 1.534 0.981
\end{filecontents*}
\begin{filecontents*}{data2.dat}
t1 a1 t4 a4 t3 a3
3.554 0.920 3.845 0.950 3.485 0.913
3.696 0.915 3.999 0.945 3.625 0.908
3.838 0.910 4.153 0.939 3.764 0.903
3.980 0.905 4.306 0.934 3.904 0.898
4.123 0.900 4.460 0.929 4.043 0.893
4.265 0.895 4.614 0.923 4.182 0.888
4.407 0.890 4.768 0.918 4.322 0.883
4.549 0.885 4.922 0.912 4.461 0.878
4.691 0.880 5.075 0.907 4.601 0.873
4.833 0.875 5.229 0.902 4.740 0.868
4.976 0.870 5.383 0.896 4.880 0.864
5.118 0.865 5.537 0.891 5.019 0.859
5.260 0.860 5.691 0.885 5.158 0.854
\end{filecontents*}
\begin{filecontents*}{data3.dat}
t1 a1 t4 a4 t3 a3
3.554 0.920 3.845 0.950 3.485 0.913
3.696 0.915 3.999 0.945 3.625 0.908
3.838 0.910 4.153 0.939 3.764 0.903
3.980 0.905 4.306 0.934 3.904 0.898
4.123 0.900 4.460 0.929 4.043 0.893
4.265 0.895 4.614 0.923 4.182 0.888
4.407 0.890 4.768 0.918 4.322 0.883
4.549 0.885 4.922 0.912 4.461 0.878
4.691 0.880 5.075 0.907 4.601 0.873
4.833 0.875 5.229 0.902 4.740 0.868
4.976 0.870 5.383 0.896 4.880 0.864
5.118 0.865 5.537 0.891 5.019 0.859
5.260 0.860 5.691 0.885 5.158 0.854
\end{filecontents*}
\begin{document}
\begin{frame}
\begin{columns}
\begin{column}{0.3\textwidth}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[scale=0.5]
\begin{groupplot}[group style={
group name=rzrxcomp,
group size=1 by 3,
xlabels at=edge bottom,
ylabels at=edge left,
vertical sep=4em
},
xmin = 0, xmax = 2,
ymin = 0.8, ymax = 1,
xtick distance = 0.2,
ytick distance = 0.2,
xlabel={$time\;[s]$},
ylabel={$mass$},
grid = both,
grid style = {dotted},
minor tick num = 1,
major grid style = {lightgray!75},
minor grid style = {lightgray!75},
width = 0.85\textwidth,
height = 0.50\textwidth,
%scale only axis,
%legend cell align = {left},
%legend pos = north east
legend style={at={(0.5,-0.3)},
anchor=north,legend columns=2},
legend cell align = {left},
]
\nextgroupplot
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data1.dat};
\addplot[smooth, Lavender, very thick] table [x = {t2}, y = {a2}] {data1.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data1.dat};
\nextgroupplot
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data2.dat};
\addplot[smooth, BurntOrange, dotted, very thick] table [x = {t4}, y = {a4}] {data2.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data2.dat};
\nextgroupplot[legend entries={n1,n2,n3,n4}]
\addlegendimage{black, very thick, no markers}
\addlegendimage{Lavender, very thick, no markers}
\addlegendimage{Violet, very thick, no markers}
\addlegendimage{BurntOrange, dotted, very thick, no markers}
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data3.dat};
\addplot[smooth, BurntOrange, dotted, very thick] table [x = {t4}, y = {a4}] {data3.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data3.dat};
\end{groupplot}
\end{tikzpicture}
\end{figure}
\end{column}
\begin{column}{0.3\textwidth}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[scale=0.5]
\begin{groupplot}[group style={
group name=rzrxcomp,
group size=1 by 3,
xlabels at=edge bottom,
ylabels at=edge left,
vertical sep=4em
},
xmin = 0, xmax = 2,
ymin = 0.8, ymax = 1,
xtick distance = 0.2,
ytick distance = 0.2,
xlabel={$time\;[s]$},
ylabel={$mass$},
grid = both,
grid style = {dotted},
minor tick num = 1,
major grid style = {lightgray!75},
minor grid style = {lightgray!75},
width = 0.85\textwidth,
height = 0.50\textwidth,
%scale only axis,
%legend cell align = {left},
%legend pos = north east
legend style={at={(0.5,-0.3)},
anchor=north,legend columns=2},
legend cell align = {left},
]
\nextgroupplot
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data1.dat};
\addplot[smooth, Lavender, very thick] table [x = {t2}, y = {a2}] {data1.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data1.dat};
\nextgroupplot
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data2.dat};
\addplot[smooth, BurntOrange, dotted, very thick] table [x = {t4}, y = {a4}] {data2.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data2.dat};
\nextgroupplot[legend entries={n1,n2,n3,n4}]
\addlegendimage{black, very thick, no markers}
\addlegendimage{Lavender, very thick, no markers}
\addlegendimage{Violet, very thick, no markers}
\addlegendimage{BurntOrange, dotted, very thick, no markers}
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data3.dat};
\addplot[smooth, BurntOrange, dotted, very thick] table [x = {t4}, y = {a4}] {data3.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data3.dat};
\end{groupplot}
\end{tikzpicture}
\end{figure}
\end{column}
\begin{column}{0.3\textwidth}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[scale=0.5]
\begin{groupplot}[group style={
group name=rzrxcomp,
group size=1 by 3,
xlabels at=edge bottom,
ylabels at=edge left,
vertical sep=4em
},
xmin = 0, xmax = 2,
ymin = 0.8, ymax = 1,
xtick distance = 0.2,
ytick distance = 0.2,
xlabel={$time\;[s]$},
ylabel={$mass$},
grid = both,
grid style = {dotted},
minor tick num = 1,
major grid style = {lightgray!75},
minor grid style = {lightgray!75},
width = 0.85\textwidth,
height = 0.50\textwidth,
%scale only axis,
%legend cell align = {left},
%legend pos = north east
legend style={at={(0.5,-0.3)},
anchor=north,legend columns=2},
legend cell align = {left},
]
\nextgroupplot
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data1.dat};
\addplot[smooth, Lavender, very thick] table [x = {t2}, y = {a2}] {data1.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data1.dat};
\nextgroupplot
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data2.dat};
\addplot[smooth, BurntOrange, dotted, very thick] table [x = {t4}, y = {a4}] {data2.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data2.dat};
\nextgroupplot[legend entries={n1,n2,n3,n4}]
\addlegendimage{black, very thick, no markers}
\addlegendimage{Lavender, very thick, no markers}
\addlegendimage{Violet, very thick, no markers}
\addlegendimage{BurntOrange, dotted, very thick, no markers}
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data3.dat};
\addplot[smooth, BurntOrange, dotted, very thick] table [x = {t4}, y = {a4}] {data3.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data3.dat};
\end{groupplot}
\end{tikzpicture}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[scale=0.34]
\begin{groupplot}[group style={
group name=rzrxcomp,
group size=1 by 3,
xlabels at=edge bottom,
ylabels at=edge left,
vertical sep=4em
},
xmin = 0, xmax = 2,
ymin = 0.8, ymax = 1,
xtick distance = 0.2,
ytick distance = 0.2,
xlabel={$time\;[s]$},
ylabel={$mass$},
grid = both,
grid style = {dotted},
minor tick num = 1,
major grid style = {lightgray!75},
minor grid style = {lightgray!75},
width = 0.85\textwidth,
height = 0.50\textwidth,
%scale only axis,
%legend cell align = {left},
%legend pos = north east
legend style={at={(0.5,-0.3)},
anchor=north,legend columns=2},
legend cell align = {left},
]
\nextgroupplot
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data1.dat};
\addplot[smooth, Lavender, very thick] table [x = {t2}, y = {a2}] {data1.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data1.dat};
\nextgroupplot
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data2.dat};
\addplot[smooth, BurntOrange, dotted, very thick] table [x = {t4}, y = {a4}] {data2.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data2.dat};
\nextgroupplot[legend entries={n1,n2,n3,n4}]
\addlegendimage{black, very thick, no markers}
\addlegendimage{Lavender, very thick, no markers}
\addlegendimage{Violet, very thick, no markers}
\addlegendimage{BurntOrange, dotted, very thick, no markers}
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data3.dat};
\addplot[smooth, BurntOrange, dotted, very thick] table [x = {t4}, y = {a4}] {data3.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data3.dat};
\end{groupplot}
\end{tikzpicture}
\end{figure}
\end{frame}
\end{document}
我尝试提供我的 WE 的类似情况。问题如下:当我尝试编译框架时,图以以下方式可视化:
另一方面,如果我将一组情节放在独立的框架中,我会得到以下结果:
我如何才能获得第二幅图上显示的比例的三列图的可视化?这与列间距有关吗?
答案1
好吧,事实证明你的问题很明显。让我解释一下:下框中的图表是相对于全宽列调整大小的。上框中的图表是相对于文本宽度三分之一的列调整大小的。当你使用相同的scale
s时,数字就会变得清晰0.34
。那么整个列的宽度是0.85\textwidth
,而宽度为三分之一的列中的图表需要大 3 倍才能补偿较小的文本宽度,即2.55\textwidth
。
对于您的代码,这意味着您可以执行类似的操作(我对您的布局进行了一些优化,例如使用\pgfplotsset
以避免冗余代码):
\documentclass[dvipsnames, aspectratio=169, 9pt]{beamer}
\usetheme{metropolis}
\usepackage{appendixnumberbeamer}
\usepackage{FiraSans}
\usefonttheme[onlymath]{serif}
\usepackage{pgf,pgfplots,pgfplotstable}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{colormaps,groupplots,dateplot}
\newcommand{\themename}{\textbf{\textsc{metropolis}}\xspace}
\begin{filecontents*}{data1.dat}
t1 a1 t2 a2 t3 a3
0.142 1.000 0.154 1.000 0.139 0.995
0.284 1.000 0.308 1.000 0.279 0.990
0.426 1.000 0.461 1.000 0.418 0.989
0.569 1.000 0.615 1.000 0.558 0.989
0.711 1.000 0.769 1.000 0.697 0.989
0.853 1.000 0.923 1.000 0.836 0.989
0.995 1.000 1.077 1.000 0.976 0.989
1.137 1.000 1.230 1.000 1.115 0.989
1.279 1.000 1.384 1.000 1.255 0.989
1.422 0.995 1.538 1.000 1.394 0.986
1.564 0.990 1.692 1.000 1.534 0.981
\end{filecontents*}
\begin{filecontents*}{data2.dat}
t1 a1 t4 a4 t3 a3
3.554 0.920 3.845 0.950 3.485 0.913
3.696 0.915 3.999 0.945 3.625 0.908
3.838 0.910 4.153 0.939 3.764 0.903
3.980 0.905 4.306 0.934 3.904 0.898
4.123 0.900 4.460 0.929 4.043 0.893
4.265 0.895 4.614 0.923 4.182 0.888
4.407 0.890 4.768 0.918 4.322 0.883
4.549 0.885 4.922 0.912 4.461 0.878
4.691 0.880 5.075 0.907 4.601 0.873
4.833 0.875 5.229 0.902 4.740 0.868
4.976 0.870 5.383 0.896 4.880 0.864
5.118 0.865 5.537 0.891 5.019 0.859
5.260 0.860 5.691 0.885 5.158 0.854
\end{filecontents*}
\begin{filecontents*}{data3.dat}
t1 a1 t4 a4 t3 a3
3.554 0.920 3.845 0.950 3.485 0.913
3.696 0.915 3.999 0.945 3.625 0.908
3.838 0.910 4.153 0.939 3.764 0.903
3.980 0.905 4.306 0.934 3.904 0.898
4.123 0.900 4.460 0.929 4.043 0.893
4.265 0.895 4.614 0.923 4.182 0.888
4.407 0.890 4.768 0.918 4.322 0.883
4.549 0.885 4.922 0.912 4.461 0.878
4.691 0.880 5.075 0.907 4.601 0.873
4.833 0.875 5.229 0.902 4.740 0.868
4.976 0.870 5.383 0.896 4.880 0.864
5.118 0.865 5.537 0.891 5.019 0.859
5.260 0.860 5.691 0.885 5.158 0.854
\end{filecontents*}
\pgfplotscreateplotcyclelist{myscheme}{
smooth, black, very thick\\
smooth, Lavender, very thick\\
smooth, BurntOrange, dotted, very thick\\
smooth, Violet, very thick\\
}
\pgfplotsset{xmin = 0, xmax = 2,
ymin = 0.8, ymax = 1,
xtick distance = 0.2,
ytick distance = 0.2,
xlabel={$time\;[s]$},
ylabel={$mass$},
grid = both,
grid style = {dotted},
minor tick num = 1,
major grid style = {lightgray!75},
minor grid style = {lightgray!75},
width = 2.55\textwidth,
height = 1.5\textwidth,
legend style={at={(0.5,-0.3)},
anchor=north,legend columns=2},
legend cell align = {left},
cycle list name=myscheme,
}
\begin{document}
\begin{frame}
\begin{columns}
\begin{column}{0.32\textwidth}
\centering
\begin{tikzpicture}[scale=0.34]
\begin{groupplot}[group style={
group name=rzrxcomp,
group size=1 by 3,
xlabels at=edge bottom,
ylabels at=edge left,
vertical sep=4em
}
]
\nextgroupplot
\addplot table [x = {t1}, y = {a1}] {data1.dat};
\addplot table [x = {t2}, y = {a2}] {data1.dat};
\addplot table [x = {t3}, y = {a3}] {data1.dat};
\nextgroupplot
\addplot table [x = {t1}, y = {a1}] {data2.dat};
\addplot table [x = {t4}, y = {a4}] {data2.dat};
\addplot table [x = {t3}, y = {a3}] {data2.dat};
\nextgroupplot[legend entries={n1,n2,n3,n4}]
\addlegendimage{black, very thick, no markers}
\addlegendimage{Lavender, very thick, no markers}
\addlegendimage{Violet, very thick, no markers}
\addlegendimage{BurntOrange, dotted, very thick, no markers}
\addplot table [x = {t1}, y = {a1}] {data3.dat};
\addplot table [x = {t4}, y = {a4}] {data3.dat};
\addplot table [x = {t3}, y = {a3}] {data3.dat};
\end{groupplot}
\end{tikzpicture}
\end{column}
\begin{column}{0.32\textwidth}
\centering
\begin{tikzpicture}[scale=0.34]
\begin{groupplot}[group style={
group name=rzrxcomp,
group size=1 by 3,
xlabels at=edge bottom,
ylabels at=edge left,
vertical sep=4em
}
]
\nextgroupplot
\addplot table [x = {t1}, y = {a1}] {data1.dat};
\addplot table [x = {t2}, y = {a2}] {data1.dat};
\addplot table [x = {t3}, y = {a3}] {data1.dat};
\nextgroupplot
\addplot table [x = {t1}, y = {a1}] {data2.dat};
\addplot table [x = {t4}, y = {a4}] {data2.dat};
\addplot table [x = {t3}, y = {a3}] {data2.dat};
\nextgroupplot[legend entries={n1,n2,n3,n4}]
\addlegendimage{black, very thick, no markers}
\addlegendimage{Lavender, very thick, no markers}
\addlegendimage{Violet, very thick, no markers}
\addlegendimage{BurntOrange, dotted, very thick, no markers}
\addplot table [x = {t1}, y = {a1}] {data3.dat};
\addplot table [x = {t4}, y = {a4}] {data3.dat};
\addplot table [x = {t3}, y = {a3}] {data3.dat};
\end{groupplot}
\end{tikzpicture}
\end{column}
\begin{column}{0.32\textwidth}
\centering
\begin{tikzpicture}[scale=0.34]
\begin{groupplot}[group style={
group name=rzrxcomp,
group size=1 by 3,
xlabels at=edge bottom,
ylabels at=edge left,
vertical sep=4em
}]
\nextgroupplot
\addplot table [x = {t1}, y = {a1}] {data1.dat};
\addplot table [x = {t2}, y = {a2}] {data1.dat};
\addplot table [x = {t3}, y = {a3}] {data1.dat};
\nextgroupplot
\addplot table [x = {t1}, y = {a1}] {data2.dat};
\addplot table [x = {t4}, y = {a4}] {data2.dat};
\addplot table [x = {t3}, y = {a3}] {data2.dat};
\nextgroupplot[legend entries={n1,n2,n3,n4}]
\addlegendimage{black, very thick, no markers}
\addlegendimage{Lavender, very thick, no markers}
\addlegendimage{Violet, very thick, no markers}
\addlegendimage{BurntOrange, dotted, very thick, no markers}
\addplot table [x = {t1}, y = {a1}] {data3.dat};
\addplot table [x = {t4}, y = {a4}] {data3.dat};
\addplot table [x = {t3}, y = {a3}] {data3.dat};
\end{groupplot}
\end{tikzpicture}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
\centering
\begin{tikzpicture}[scale=0.34]
\begin{groupplot}[group style={
group name=rzrxcomp,
group size=1 by 3,
xlabels at=edge bottom,
ylabels at=edge left,
vertical sep=4em
},
width = 0.85\textwidth,
height = 0.50\textwidth,
]
\nextgroupplot
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data1.dat};
\addplot[smooth, Lavender, very thick] table [x = {t2}, y = {a2}] {data1.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data1.dat};
\nextgroupplot
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data2.dat};
\addplot[smooth, BurntOrange, dotted, very thick] table [x = {t4}, y = {a4}] {data2.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data2.dat};
\nextgroupplot[legend entries={n1,n2,n3,n4}]
\addlegendimage{black, very thick, no markers}
\addlegendimage{Lavender, very thick, no markers}
\addlegendimage{Violet, very thick, no markers}
\addlegendimage{BurntOrange, dotted, very thick, no markers}
\addplot[smooth, black, very thick] table [x = {t1}, y = {a1}] {data3.dat};
\addplot[smooth, BurntOrange, dotted, very thick] table [x = {t4}, y = {a4}] {data3.dat};
\addplot[smooth, Violet, very thick] table [x = {t3}, y = {a3}] {data3.dat};
\end{groupplot}
\end{tikzpicture}
\end{frame}
\end{document}
看起来像这样: