我正在尝试在 beamer 中插入多个 tikzpictures(散点图)。我尝试按照针对类似问题给出的提示进行操作,但仍然无法编译。这是我在文章格式中使用的原始代码:
\documentclass[mathserif,10pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{adjustbox}
\usepackage[beamer,customcolors]{hf-tikz}
\usepackage{pgfplots}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{shadows,arrows}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{backgrounds}
\usetikzlibrary{calc}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.text}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.7}
\usetheme{Warsaw}
\usecolortheme{default}
\begin{document}
\begin{frame}{Correlations of parents and preschoolers scores}
\begin{figure}[!htbp]
\begin{center}
\begin{minipage}[b]{0.45\textwidth}
\centering
\begin{tikzpicture}[scale=0.6]
\begin{axis}[%
legend style={at={(0.7,0.5)},anchor=south west,font=\footnotesize},
xlabel=Parents awareness score; pre-assessment,
ylabel=Child's behavior score; pre-assessment,
xshift=0.1cm,
yshift=0.1cm]%
\addplot [scatter,mark=+,only marks]
table []{values.data};
\addplot[draw=none]
table[
header=false,
y={create col/linear regression},
] {values.data};
\addplot[domain=5:30,black]
{\pgfplotstableregressiona*x + \pgfplotstableregressionb};
\end{axis}
\end{tikzpicture}
\end{minipage}
\hfill
\begin{minipage}[b]{0.45\textwidth}
\centering
\begin{tikzpicture}[scale=0.6]
\begin{axis}[%
legend style={at={(0.7,0.5)},anchor=south west,font=\footnotesize},
xlabel=Parents awareness score; post-assessment,
ylabel=Child's behavior score; post-assessment,
xshift=0.1cm,
yshift=0.1cm]%
\addplot [scatter,mark=+,only marks]
table []{values2.data};
\addplot[draw=none]
table[
header=false,
y={create col/linear regression},
] {values2.data};
\addplot[domain=5:30,black]
{\pgfplotstableregressiona*x + \pgfplotstableregressionb};
\end{axis}
\end{tikzpicture}
\end{minipage}
\end{center}
\caption[Correlation between parents awareness score and child's behavior score amid the intervention sample]{Correlation between parents awareness score and child's behavior score amid the intervention sample.}
\end{figure}
\end{frame}
\end{document}
答案1
你有
\includegraphics[width=0.8\linewidth]{
\begin{tikzpicture}[scale=0.9]..}
这是行不通的,争论的焦点\includegraphics
是文件名但是这里没有图像,只有 tex 代码的 tikz 图片,只需删除\includegraphics
命令即可。
\documentclass[mathserif,10pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{adjustbox}
\usepackage[beamer,customcolors]{hf-tikz}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{shadows,arrows}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{backgrounds}
\usetikzlibrary{calc}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.text}
\usepgfplotslibrary{groupplots}
\pgfplotsset{compat=1.7}
\usetheme{Warsaw}
\usecolortheme{default}
\begin{document}
\begin{frame}{Correlations of parents and preschoolers scores}
\begin{columns}
\column{0.5\textwidth}
\begin{minipage}[c][0.4\textheight][c]{\linewidth}
\centering
\begin{tikzpicture}[scale=0.9]
\begin{axis}[%
legend style={at={(0.7,0.5)},anchor=south west,font=\footnotesize},
xlabel=Parents awareness score; pre-assessment,
ylabel=Child's behavior score; pre-assessment,
xshift=0.1cm,
yshift=0.1cm]%
%\addplot [scatter,mark=+,only marks] table []{values.data};
%\addplot[draw=none]
% table[
% header=false,
% y={create col/linear regression},
% ] {values.data};
%\addplot[domain=5:30,black]
% {\pgfplotstableregressiona*x + \pgfplotstableregressionb};
\end{axis}
\end{tikzpicture}
\end{minipage}
\begin{minipage}[c][0.4\textheight][c]{\linewidth}
\centering
\begin{tikzpicture}[scale=0.9]
\begin{axis}[%
legend style={at={(0.7,0.5)},anchor=south west,font=\footnotesize},
xlabel=Parents awareness score; post-assessment,
ylabel=Child's behavior score; post-assessment,
xshift=0.1cm,
yshift=0.1cm]%
%\addplot [scatter,mark=+,only marks]
%table []{values2.data};
%\addplot[draw=none]
% table[
% header=false,
% y={create col/linear regression},
% ] {values2.data};
% \addplot[domain=5:30,black]
% {\pgfplotstableregressiona*x + \pgfplotstableregressionb};
\end{axis}
\end{tikzpicture}
\end{minipage}
\column{0.5\textwidth}
\begin{minipage}[c][0.4\textheight][c]{\linewidth}
\centering
\begin{tikzpicture}[scale=0.9]
\begin{axis}[%
legend style={at={(0.7,0.5)},anchor=south west,font=\footnotesize},
xlabel=Parents awareness score; pre-assessment,
ylabel=Child's behavior score; pre-assessment,
xshift=0.1cm,
yshift=0.1cm]%
% \addplot [scatter,mark=+,only marks]
% table []{values3.data};
% \addplot[draw=none]
% table[
% header=false,
% y={create col/linear regression},
% ] {values3.data};
% \addplot[domain=5:30,black]
% {\pgfplotstableregressiona*x + \pgfplotstableregressionb};
\end{axis}
\end{tikzpicture}
\end{minipage}
\begin{minipage}[c][0.4\textheight][c]{\linewidth}
\centering
\begin{tikzpicture}[scale=0.9]
\begin{axis}[%
legend style={at={(0.7,0.5)},anchor=south west,font=\footnotesize},
xlabel=Parents awareness score; post-assessment,
ylabel=Child's behavior score; post-assessment,
xshift=0.1cm,
yshift=0.1cm]%
%\addplot [scatter,mark=+,only marks]
%table []{values4.data};
%\addplot[draw=none]
% table[
% header=false,
% y={create col/linear regression},
% ] {values4.data};
% \addplot[domain=5:30,black]
% {\pgfplotstableregressiona*x + \pgfplotstableregressionb};
\end{axis}
\end{tikzpicture}
\end{minipage}
\end{columns}
\end{frame}
\end{document}