![联合和边际 pdf 需要 PGFPLOT 帮助](https://linux22.com/image/410399/%E8%81%94%E5%90%88%E5%92%8C%E8%BE%B9%E9%99%85%20pdf%20%E9%9C%80%E8%A6%81%20PGFPLOT%20%E5%B8%AE%E5%8A%A9.png)
答案1
这是为了给你一个开始。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{3d}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[declare function={%
f(\x,\y)=(1/(2*pi))*exp(-pow(\x-1,2)/2-pow(\y-1,2)/2);}]
\begin{axis}[zmax=1/pi,zmin=-1/pi,colormap/viridis]
\begin{scope}[canvas is xy plane at z=-1/pi]
\draw[color of colormap=900] (1,1) circle[radius=0.5];
\draw[color of colormap=700] (1,1) circle[radius=1];
\draw[color of colormap=500] (1,1) circle[radius=1.5];
\draw[color of colormap=300] (1,1) circle[radius=2];
\draw[color of colormap=100] (1,1) circle[radius=2.5];
\end{scope}
\addplot3[color=red,thick,samples y=0,domain=-2:4] (x,4,{f(x,1)});
\addplot3[color=blue,thick,samples y=0,domain=-2:4] (-2,x,{f(1,x)});
\addplot3[mesh,domain=-2:4,domain y=-2:4] {f(x,y)};
\addplot3[color=red,thick,samples y=0,domain=4:-2] (x,1,{f(x,1)})
-- (-2,1,{f(1,1)}); ;
\addplot3[color=blue,thick,samples y=0,domain=-2:4] (1,x,{f(1,x)}) --
(1,4,{f(1,1)});
\end{axis}
\end{tikzpicture}
\end{document}
答案2
首先,我非常感谢 Schrondinger cat 帮助我入门。我生成了 pgfplots。
]2