我将一个三变量函数绘制成四个二变量函数,四个图中的每一个都将第三个变量固定在特定值。示例如下:
对于任何感兴趣的人,它的源代码是:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\begin{tikzpicture}
\begin{axis}[
name=axis1,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(x*y)^(0.5) + (0.5)*(x)^(0.5) + (0.5)*(y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 1 };
\end{axis}
\end{tikzpicture}
我的目标是将这四个图组成一个 2x2 数组/网格。我不确定“minipage”在这里是否是个好主意,但这是我一直采用的方法。
我还想将 z 轴设置为特定值(500),以使这两个变量函数之间的比较更清晰,但我可能会将其保存为另一个问题(如果我在这里得到答案,我仍然想将其作为问题提出,以便其他人可以找到它)。
单独来看,我的图表编译得很好,然而当嵌入到图形和小页面环境中时,LaTeX 并没有返回任何好的东西。
以下是我目前获得的源代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\begin{document}
\section{Plot with one variable held constant}
Consider $A(x,y,z)$ for a particular value of z:
$$ \mathfrak{A} = \frac{\sqrt{x y z}}{6} + \frac{\sqrt{x y} + \sqrt{y z} + \sqrt{x z}}{2} + x + y + z $$
$$For z = 1:$$
$$For z = 10$$
$$For z = 20:$$
$$For z = 30:$$
\begin{figure}%
\begin{minipage}
\centering
\begin{subfigure}
\begin{tikzpicture}
\begin{axis}[
name=axis1,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(x*y)^(0.5) + (0.5)*(x)^(0.5) + (0.5)*(y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 1 };
\end{axis}
\end{tikzpicture}
\end{subfigure}%
\hfill
\centering
\begin{subfigure}
\begin{tikzpicture}
\begin{axis}[
name=axis2,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(10*x*y)^(0.5) + (0.5)*(10*x)^(0.5) + (0.5)*(10*y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 10 };
\end{axis}
\end{tikzpicture}
\end{subfigure}%
\hfill
\centering
\begin{subfigure}
\begin{tikzpicture}
\begin{axis}[
name=axis3,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(20*x*y)^(0.5) + (0.5)*(20*x)^(0.5) + (0.5)*(20*y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 20 };
\end{axis}
\end{tikzpicture}
\end{subfigure}%
\\
\centering
\begin{subfigure}
\begin{tikzpicture}
\begin{axis}[
name=axis4,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(30*x*y)^(0.5) + (0.5)*(30*x)^(0.5) + (0.5)*(30*y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 30 };
\end{axis}
\end{tikzpicture}
\end{subfigure}%
\hfill
\end{minipage}%
\end{figure}
\end{document}
答案1
这里有两个提案,要么是表格中的子图,要么只是一个 Ti钾Zy 矩阵。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{subcaption}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\section{Plot with one variable held constant}
% Consider $A(x,y,z)$ for a particular value of z:
% \[ \mathfrak{A} = \frac{\sqrt{x y z}}{6} + \frac{\sqrt{x y} + \sqrt{y z} +
% \sqrt{x z}}{2} + x + y + z \]
%
% \[For z = 1:\]
%
% \[For z = 10\]
%
%
% \[For z = 20:\]
%
% \[For z = 30:\]
\begin{figure}[htb]%
\pgfplotsset{width=0.9\linewidth,zmax=500}
\centering
\begin{tabular}{cc}
\begin{subfigure}{0.45\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
name=axis1,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(x*y)^(0.5) + (0.5)*(x)^(0.5) + (0.5)*(y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 1 };
\end{axis}
\end{tikzpicture}
\end{subfigure}%
&
\begin{subfigure}{0.45\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
name=axis2,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(10*x*y)^(0.5) + (0.5)*(10*x)^(0.5) + (0.5)*(10*y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 10 };
\end{axis}
\end{tikzpicture}
\end{subfigure} \\
\begin{subfigure}{0.45\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
name=axis3,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(20*x*y)^(0.5) + (0.5)*(20*x)^(0.5) + (0.5)*(20*y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 20 };
\end{axis}
\end{tikzpicture}
\end{subfigure}%
&
\begin{subfigure}{0.45\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
name=axis4,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(30*x*y)^(0.5) + (0.5)*(30*x)^(0.5) + (0.5)*(30*y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 30 };
\end{axis}
\end{tikzpicture}
\end{subfigure}%
\end{tabular}
\caption{With subfigures from the \texttt{subcation} package.}
\end{figure}
\begin{figure}[htb]%
\pgfplotsset{width=0.45\linewidth,zmax=500}
\centering
\begin{tikzpicture}
\matrix{
\begin{axis}[
name=axis1,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(x*y)^(0.5) + (0.5)*(x)^(0.5) + (0.5)*(y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 1 };
\end{axis}
&
\begin{axis}[
name=axis2,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(10*x*y)^(0.5) + (0.5)*(10*x)^(0.5) + (0.5)*(10*y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 10 };
\end{axis} \\
\begin{axis}[
name=axis3,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(20*x*y)^(0.5) + (0.5)*(20*x)^(0.5) + (0.5)*(20*y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 20 };
\end{axis}
&
\begin{axis}[
name=axis4,
grid=major,
view={35}{45},
]
\addplot3+ [
mesh,
scatter,
faceted color=blue,
samples=10,
domain=0:100,y domain=0:100
] {0.1667*(30*x*y)^(0.5) + (0.5)*(30*x)^(0.5) + (0.5)*(30*y)^(0.5) + (0.5)*(x*y)^(0.5) + x + y + 30 };
\end{axis}\\
};
\end{tikzpicture}
\caption{With a \texttt{tikz} matrix.}
\end{figure}
\end{document}
顺便说一句,您的示例没有编译,因为您没有在序言中加载相关的包,并且$$ ... $$
需要被替换\[ ... \]
。