![填充由三维图中给定点映射的自定义平面](https://linux22.com/image/439213/%E5%A1%AB%E5%85%85%E7%94%B1%E4%B8%89%E7%BB%B4%E5%9B%BE%E4%B8%AD%E7%BB%99%E5%AE%9A%E7%82%B9%E6%98%A0%E5%B0%84%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E5%B9%B3%E9%9D%A2.png)
对于我的多目标问题,我已经获得了有效前沿,我想使用 latex 中的 3D 图直观地显示它。由于这些点没有矩阵结构,因此我得到的是线图而不是曲面图。以下是 MWE:
\documentclass[a4paper, 12pt]{article}
\usepackage{pgfplots}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}{unbounded coords=jump, view={70}{40}, colormap/viridis, scale only axis, scaled ticks=false}
\addplot3[surf]
coordinates{
(9715658,5237.548,1662.979)
(8905129.8213686,5248.96044843318,1863.6983325056)
(8061017,5509.97,1858.004)
(7917754.57021608,5816.5781775536,2267.9700413312)
(7868445.94326526,6104.8328939749,2472.8959922048)
(8149171,6132.452,2808.096)
(9375859,7471.631,3732.035)
(12183200,7869.911,3911.075)
(9715658,5237.548,1662.979)
};
\end{axis}
\end{tikzpicture}
\caption{3D plot}\label{fig1}
\end{figure}
\end{document}
答案1
始终设置兼容级别 - 参见代码。您遇到的问题与此处相同:pgfplots 表格中的曲面图
- 您的数据格式错误(只有一行)
插入空白行会触发surf
将其视为表面,尽管这可能不是您想要的:
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}{unbounded coords=jump, view={70}{40}, colormap/viridis, scale only axis, scaled ticks=false}
\addplot3[surf]
coordinates{
(9715658,5237.548,1662.979)
(8905129.8213686,5248.96044843318,1863.6983325056)
(8061017,5509.97,1858.004)
(7917754.57021608,5816.5781775536,2267.9700413312)
(7868445.94326526,6104.8328939749,2472.8959922048)
(8149171,6132.452,2808.096)
(9375859,7471.631,3732.035)
(12183200,7869.911,3911.075)
(9715658,5237.548,1662.979)
};
\end{axis}
\end{tikzpicture}
\end{document}
编辑:
需要明确的是决不知道你想用格式错误的数据做什么。这些点不共面,它们自己也不构成表面。话虽如此,人们可以猜到你想要一个跨度表面,也许并不关心它是如何形成的!?。有很多方法可以做到这一点 - 这里有一个带有插值点的示例:
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}{unbounded coords=jump, view={70}{40}, colormap/viridis, scale only axis, scaled ticks=false}
\addplot3[surf, mark=*]
coordinates{
(9715658,5237.548,1662.979)
(8905129.8213686,5248.96044843318,1863.6983325056)
(8061017,5509.97,1858.004)
(7917754.57021608,5816.5781775536,2267.9700413312)
(7868445.94326526,6104.8328939749,2472.8959922048)
(8149171,6132.452,2808.096)
(9375859,7471.631,3732.035)
(12183200,7869.911,3911.075)
(9715658,5237.548,1662.979)
(10000000,5540.93,1922.03)
(10200000,5754.29,2104.24)
(10500000,6074.33,2377.56)
(11000000,6607.73,2833.1)
(11500000,7141.13,3288.63)
(12000000,7674.53,3744.16)
(12183200,7869.911,3911.075)
};
\end{axis}
\end{tikzpicture}
\end{document}