我想要两个并排的 3D 图,一个显示图的 3D 视图,另一个显示顶视图。我取出图片并将它们放入 MWE 中,但结果还是一样错误(附加在末尾)。我尝试使用图形和子图来做这件事,但也没有成功。我目前的方法是使用具有 20.5\textwidth
列的表格环境,然后将轴的宽度设置为\linewidth
每列。
我有点不明白为什么每张图片不占据文本宽度的一半。
MWE/代码:
\documentclass[11pt, a4paper, ngerman, footsepline, headsepline]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{geometry}
\usepackage{pgfplots}
% TIKZ settings
\pgfplotsset{compat = newest}
\usepgfplotslibrary{fillbetween}
% For debugging
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{1pt}
% Geometry of the target document
\geometry{nomarginpar, top=30mm, bottom=35mm, left=25mm, right=25mm}
\begin{document}
\begin{tabular}[h]{@{}p{.5\textwidth}@{}p{.5\textwidth}@{}}
\fbox{
\begin{tikzpicture}[
declare function = {
f(\x,\y) = (\x*\x - \y*\y)*exp(\x*\x - \y*\y);
},
]
\begin{axis}[
xmin = -1.5, xmax = 1.5,
ymin = -1.5, ymax = 1.5,
axis lines = center,
domain=-1:1,
domain y=-1:1,
xlabel = {x},
ylabel = {y},
zlabel = {z},
scale mode=scale uniformly,
width = \linewidth,
colormap/viridis,
]
% Add the base plots
\addplot3[name path=functionf,
samples = 50,
samples y = 50,
contour filled={levels={0,0.25,0.5,1,5,10}},
shader=interp,
opacity=0.6]
{f(x,y)};
% Add the zero lines
\addplot3[thick](x,x,0) node[pos=1,anchor=south west]{\(y=x\)};
\addplot3[thick](x,-x,0) node[pos=1,anchor=north west]{\(y=-x\)};
\end{axis}
\end{tikzpicture}
}
&
\fbox{
\begin{tikzpicture}[
outer sep=0pt,
declare function = {
f(\x,\y) = (\x*\x - \y*\y)*exp(\x*\x - \y*\y);
},
]
\begin{axis}[
axis lines = center,
domain=-1:1,
domain y=-1:1,
view={0}{90},
xlabel = {x},
ylabel = {y},
zlabel = {z},
scale mode=scale uniformly,
width = \linewidth,
colormap/viridis,
]
% Add the base plots
\addplot3[name path=functionf,
samples = 50,
samples y = 50,
contour filled={levels={0,0.25,0.5,1,5,10}},
shader=interp,
opacity=0.6]
{f(x,y)};
% Add the zero lines
\addplot3[thick](x,x,0) node[pos=0.8,anchor=south east]{\(y=x\)};
\addplot3[thick](x,-x,0) node[pos=0.8,anchor=north east]{\(y=-x\)};
\end{axis}
\end{tikzpicture}
}
\end{tabular}
\end{document}
编辑:MWE 当前的样子(添加了标题以可视化文本宽度):
颜色的锯齿状边缘只是 pdf 查看器的渲染问题。