addplot3[surf] 创建线而不是表面

addplot3[surf] 创建线而不是表面

我一直在尝试创建表面图,但无法使其工作。任何帮助都将不胜感激。我尝试使用,surf它只会生成线条而不是表面(图 1)。注意:虽然我最初能够生成输出,但该surf图不再编译:“Package tikz Error”。我尝试使用带有 -shell-escape 标志的 pdflatex 和 lualatex 进行编译。

在此处输入图片描述

图1

我也尝试使用patch样式图。这会产生乱码(图 2)

在此处输入图片描述

图 2

梅威瑟:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\usepgfplotslibrary{patchplots}
\tikzexternalize

\begin{document}
\begin{figure}[t]
  \centering

  \tikzsetnextfilename{surface_plot}
  \begin{tikzpicture}
    \begin{axis} [
      height=12cm,
      width=15cm,
      grid=major,
      grid style={dotted},
      colormap/jet,
      mesh/ordering=x varies
    ]
      %\addplot3[patch,patch type=biquadratic,shader=faceted interp,patch refines=3] coordinates {
      \addplot3[surf] coordinates {

(-6,-6,446.788)  (-5,-6,423.361)  (-4,-6,413.264)  (-3,-6,402.349)  (-2,-6,388.948)  (-1,-6,391.747)  (0,-6,386.874)  (1,-6,423.778)  (2,-6, 439.19)  (3,-6,449.074)  (4,-6,462.155)  (5,-6,484.399)  (6,-6,505.412)
(-6,-5, 423.48)  (-5,-5,392.382)  (-4,-5,406.696)  (-3,-5,392.592)  (-2,-5,371.158)  (-1,-5,384.142)  (0,-5,394.666)  (1,-5,408.105)  (2,-5, 422.51)  (3,-5,420.173)  (4,-5,445.816)  (5,-5,464.731)  (6,-5,485.349)
(-6,-4,402.646)  (-5,-4,371.879)  (-4,-4,376.239)  (-3,-4,396.874)  (-2,-4,382.761)  (-1,-4,386.665)  (0,-4,397.148)  (1,-4,410.875)  (2,-4,425.998)  (3,-4,385.143)  (4,-4,420.458)  (5,-4,438.432)  (6,-4,    458)
(-6,-3,423.219)  (-5,-3,370.582)  (-4,-3,464.786)  (-3,-3,443.921)  (-2,-3,425.196)  (-1,-3,427.138)  (0,-3,438.002)  (1,-3, 453.97)  (2,-3,473.021)  (3,-3,418.583)  (4,-3,435.887)  (5,-3,414.993)  (6,-3,475.148)
(-6,-2,401.995)  (-5,-2,385.612)  (-4,-2,438.956)  (-3,-2,418.583)  (-2,-2,400.093)  (-1,-2,400.773)  (0,-2, 410.58)  (1,-2,426.024)  (2,-2, 444.92)  (3,-2,397.131)  (4,-2,413.739)  (5,-2,431.741)  (6,-2,451.267)
(-6,-1,382.978)  (-5,-1,335.274)  (-4,-1,416.598)  (-3,-1,396.718)  (-2,-1,378.348)  (-1,-1,377.455)  (0,-1,32.0089)  (1,-1,400.683)  (2,-1,419.918)  (3,-1,377.371)  (4,-1,393.286)  (5,-1,374.648)  (6,-1,429.077)
(-6, 0,365.902)  (-5, 0,350.965)  (-4, 0,397.527)  (-3, 0, 378.36)  (-2, 0,360.454)  (-1, 0,358.447)  (0, 0,    363)  (1, 0,381.147)  (2, 0,401.177)  (3, 0,362.155)  (4, 0,378.174)  (5, 0,395.513)  (6, 0, 414.34)
(-6, 1,372.511)  (-5, 1,326.945)  (-4, 1,407.215)  (-3, 1,388.646)  (-2, 1,371.945)  (-1, 1,371.003)  (0, 1,380.027)  (1, 1,396.414)  (2, 1,416.602)  (3, 1,374.897)  (4, 1,391.276)  (5, 1, 373.32)  (6, 1,428.284)
(-6, 2,391.149)  (-5, 2,376.191)  (-4, 2,406.941)  (-3, 2,369.633)  (-2, 2,393.583)  (-1, 2,394.184)  (0, 2,404.263)  (1, 2,420.588)  (2, 2,  440.5)  (3, 2,416.631)  (4, 2,374.948)  (5, 2,391.855)  (6, 2,418.511)
(-6, 3,375.967)  (-5, 3,361.698)  (-4, 3,357.421)  (-3, 3,368.273)  (-2, 3,377.106)  (-1, 3,378.664)  (0, 3,369.175)  (1, 3, 382.42)  (2, 3,397.821)  (3, 3,377.942)  (4, 3,384.944)  (5, 3,387.862)  (6, 3,424.429)
(-6, 4,396.478)  (-5, 4,381.554)  (-4, 4,376.162)  (-3, 4,388.843)  (-2, 4,375.881)  (-1, 4,378.384)  (0, 4, 355.14)  (1, 4,403.654)  (2, 4,419.779)  (3, 4,398.599)  (4, 4,407.113)  (5, 4,426.715)  (6, 4,448.245)
(-6, 5,409.364)  (-5, 5,380.492)  (-4, 5,387.843)  (-3, 5,360.034)  (-2, 5, 362.23)  (-1, 5,364.909)  (0, 5,358.321)  (1, 5,363.226)  (2, 5,379.325)  (3, 5,397.152)  (4, 5,410.086)  (5, 5,433.909)  (6, 5,460.548)
(-6, 6, 423.99)  (-5, 6,408.967)  (-4, 6,400.475)  (-3, 6,372.922)  (-2, 6,371.116)  (-1, 6, 373.92)  (0, 6,384.778)  (1, 6,  398.8)  (2, 6, 415.62)  (3, 6,420.127)  (4, 6,436.064)  (5, 6,461.957)  (6, 6,491.123)

      };
    \end{axis}
  \end{tikzpicture}     
\end{figure}
\end{document}

太感谢了。

答案1

PGFPlots 需要知道每行数据中有多少个坐标。使用您当前使用的格式,它无法推断此信息,因为它只能看到一行长坐标(换行符不足以中断序列)。

为了使情节正确运作,你可以

  • mesh/cols=13
  • mesh/rows=13
  • 在第一行数据后添加一个空行

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\usepgfplotslibrary{patchplots}
\tikzexternalize

\begin{document}
\begin{figure}[t]
  \centering

  \tikzsetnextfilename{surface_plot}
  \begin{tikzpicture}
    \begin{axis} [
      height=12cm,
      width=15cm,
      grid=major,
      grid style={dotted},
      colormap/jet,
      mesh/ordering=x varies,
      mesh/cols=13
    ]
      \addplot3[surf] coordinates {
(-6,-6,446.788)  (-5,-6,423.361)  (-4,-6,413.264)  (-3,-6,402.349)  (-2,-6,388.948)  (-1,-6,391.747)  (0,-6,386.874)  (1,-6,423.778)  (2,-6, 439.19)  (3,-6,449.074)  (4,-6,462.155)  (5,-6,484.399)  (6,-6,505.412)
(-6,-5, 423.48)  (-5,-5,392.382)  (-4,-5,406.696)  (-3,-5,392.592)  (-2,-5,371.158)  (-1,-5,384.142)  (0,-5,394.666)  (1,-5,408.105)  (2,-5, 422.51)  (3,-5,420.173)  (4,-5,445.816)  (5,-5,464.731)  (6,-5,485.349)
(-6,-4,402.646)  (-5,-4,371.879)  (-4,-4,376.239)  (-3,-4,396.874)  (-2,-4,382.761)  (-1,-4,386.665)  (0,-4,397.148)  (1,-4,410.875)  (2,-4,425.998)  (3,-4,385.143)  (4,-4,420.458)  (5,-4,438.432)  (6,-4,    458)
(-6,-3,423.219)  (-5,-3,370.582)  (-4,-3,464.786)  (-3,-3,443.921)  (-2,-3,425.196)  (-1,-3,427.138)  (0,-3,438.002)  (1,-3, 453.97)  (2,-3,473.021)  (3,-3,418.583)  (4,-3,435.887)  (5,-3,414.993)  (6,-3,475.148)
(-6,-2,401.995)  (-5,-2,385.612)  (-4,-2,438.956)  (-3,-2,418.583)  (-2,-2,400.093)  (-1,-2,400.773)  (0,-2, 410.58)  (1,-2,426.024)  (2,-2, 444.92)  (3,-2,397.131)  (4,-2,413.739)  (5,-2,431.741)  (6,-2,451.267)
(-6,-1,382.978)  (-5,-1,335.274)  (-4,-1,416.598)  (-3,-1,396.718)  (-2,-1,378.348)  (-1,-1,377.455)  (0,-1,32.0089)  (1,-1,400.683)  (2,-1,419.918)  (3,-1,377.371)  (4,-1,393.286)  (5,-1,374.648)  (6,-1,429.077)
(-6, 0,365.902)  (-5, 0,350.965)  (-4, 0,397.527)  (-3, 0, 378.36)  (-2, 0,360.454)  (-1, 0,358.447)  (0, 0,    363)  (1, 0,381.147)  (2, 0,401.177)  (3, 0,362.155)  (4, 0,378.174)  (5, 0,395.513)  (6, 0, 414.34)
(-6, 1,372.511)  (-5, 1,326.945)  (-4, 1,407.215)  (-3, 1,388.646)  (-2, 1,371.945)  (-1, 1,371.003)  (0, 1,380.027)  (1, 1,396.414)  (2, 1,416.602)  (3, 1,374.897)  (4, 1,391.276)  (5, 1, 373.32)  (6, 1,428.284)
(-6, 2,391.149)  (-5, 2,376.191)  (-4, 2,406.941)  (-3, 2,369.633)  (-2, 2,393.583)  (-1, 2,394.184)  (0, 2,404.263)  (1, 2,420.588)  (2, 2,  440.5)  (3, 2,416.631)  (4, 2,374.948)  (5, 2,391.855)  (6, 2,418.511)
(-6, 3,375.967)  (-5, 3,361.698)  (-4, 3,357.421)  (-3, 3,368.273)  (-2, 3,377.106)  (-1, 3,378.664)  (0, 3,369.175)  (1, 3, 382.42)  (2, 3,397.821)  (3, 3,377.942)  (4, 3,384.944)  (5, 3,387.862)  (6, 3,424.429)
(-6, 4,396.478)  (-5, 4,381.554)  (-4, 4,376.162)  (-3, 4,388.843)  (-2, 4,375.881)  (-1, 4,378.384)  (0, 4, 355.14)  (1, 4,403.654)  (2, 4,419.779)  (3, 4,398.599)  (4, 4,407.113)  (5, 4,426.715)  (6, 4,448.245)
(-6, 5,409.364)  (-5, 5,380.492)  (-4, 5,387.843)  (-3, 5,360.034)  (-2, 5, 362.23)  (-1, 5,364.909)  (0, 5,358.321)  (1, 5,363.226)  (2, 5,379.325)  (3, 5,397.152)  (4, 5,410.086)  (5, 5,433.909)  (6, 5,460.548)
(-6, 6, 423.99)  (-5, 6,408.967)  (-4, 6,400.475)  (-3, 6,372.922)  (-2, 6,371.116)  (-1, 6, 373.92)  (0, 6,384.778)  (1, 6,  398.8)  (2, 6, 415.62)  (3, 6,420.127)  (4, 6,436.064)  (5, 6,461.957)  (6, 6,491.123)

      };
    \end{axis}
  \end{tikzpicture}     
\end{figure}
\end{document}

相关内容