是否可以推斷 pgfplots 中 3d 繪圖的數據?

是否可以推斷 pgfplots 中 3d 繪圖的數據?

我有幾個測量要繪製,並且想使用 3d 表面之類的東西pgfplots。我有一個框架作為外邊框和一個網格作為測量光柵。測量值是在每個網格單元的中間取得的。在繪製整個表面時,我想推斷數據直到框架外邊界,以便用表面填充整個表面。

到目前為止,這是我所掌握的:

\documentclass{standalone}
\usepackage[locale = DE]{siunitx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\SendSettingsToPgf
\pgfplotsset{%
    ,grid style={black, thin}
    ,y label style={rotate=-90}
}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[%
            ,colorbar
            ,view={0}{90}
            ,xmin=0
            ,xmax=3910
            ,ymin=0
            ,ymax=2040
            ,width=391pt
            ,height=204pt
            ,grid=major
            ,xlabel=Width $b_\mathrm{frame}$ in \si{\milli\metre}
            ,ylabel=Height $h_\mathrm{frame}$ in \si{\milli\metre}
        ]
        \addplot3[%
            ,surf
            ,shader=interp
        ] file {data.dat};
    \end{axis}
\end{tikzpicture}
\end{document}

看起來data.dat像:

85  1955    0.97
255 1955    1.86
425 1955    2.44
595 1955    2.23
765 1955    2.17
935 1955    2.35
1105    1955    2.21
1275    1955    2.53
1445    1955    2.58
1615    1955    2.64
1785    1955    2.6
1955    1955    2.03
2125    1955    2.5
2295    1955    2.32
2465    1955    2.22
2635    1955    2
2805    1955    1.59
2975    1955    2.23
3145    1955    2.18
3315    1955    2.07
3485    1955    2.38
3655    1955    2.48
3825    1955    1.42

85  1785    1.3
255 1785    1.41
...

所以我需要取得所有值x = 0y = 0點。既然pgfplots能夠進行插值,也許它也能夠進行推論。

看起來就是這樣:

在此輸入影像描述

加分兩點:

  • 我想將網格(不是刻度線)放到測量光柵上,例如,每個 170 毫米
  • 我想將顏色圖標記為speed $v$ in \si{\metre\per\second}

答案1

關於主要問題:

pgfplots沒有內建的推斷支持。

您需要透過外部產品(可能是octave或 )來計算它們matlab

答案2

(部分解決方案)我不知道這樣的功能,抱歉。但我可以幫你完成這兩項額外的任務。開始了。

\documentclass{standalone}
\usepackage{filecontents}
\usepackage[locale = DE]{siunitx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\SendSettingsToPgf
\pgfplotsset{%
    ,grid style={black, thin}
    ,y label style={rotate=-90}}
\begin{document}
\begin{filecontents*}{data.dat}
85  1955    0.97
255 1955    1.86
425 1955    2.44
595 1955    2.23
765 1955    2.17
935 1955    2.35
1105    1955    2.21
1275    1955    2.53
1445    1955    2.58
1615    1955    2.64
1785    1955    2.6
1955    1955    2.03
2125    1955    2.5
2295    1955    2.32
2465    1955    2.22
2635    1955    2
2805    1955    1.59
2975    1955    2.23
3145    1955    2.18
3315    1955    2.07
3485    1955    2.38
3655    1955    2.48
3825    1955    1.42
85  1785    1.3
255 1785    1.41 
\end{filecontents*}
\begin{tikzpicture}
    \begin{axis}[%
            ,colorbar
            ,view={0}{90}
            ,xmin=0
            ,xmax=3910
            ,ymin=0
            ,ymax=2040
            ,width=391pt
            ,height=204pt
            ,grid=major
            ,xlabel=Width $b_\mathrm{frame}$ in \si{\milli\metre}
            ,ylabel=Height $h_\mathrm{frame}$ in \si{\milli\metre}
,xtick={0,170,...,3910}
,ytick={0,170,...,2040}
,tick style={black}
,x tick label style={rotate=90}
        ]
        \addplot3[
            ,surf, 
            ,shader=interp
        ] file {data.dat};
    \end{axis}
\node[xshift=2mm, yshift=4.5mm, rotate=90] at (current bounding box.east){Speed $v$ in \si{\metre\per\second}};
\end{tikzpicture}
\end{document}

在此輸入影像描述

編輯:我們可以透過使用主要和次要刻度來擴展我們的範例,以獲得網格比其標籤更頻繁的效果。我添加了另一個帶有兩個空白點的 3D 圖來控制 z 軸上的最小值和最大值,它會影響顏色圖。

\documentclass{standalone}
\usepackage{filecontents}
\usepackage[locale = DE]{siunitx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\SendSettingsToPgf
\pgfplotsset{%
    ,grid style={black, thin}
    ,y label style={rotate=-90}}
\begin{document}
\begin{filecontents*}{data.dat}
85  1955    0.97
255 1955    1.86
425 1955    2.44
595 1955    2.23
765 1955    2.17
935 1955    2.35
1105    1955    2.21
1275    1955    2.53
1445    1955    2.58
1615    1955    2.64
1785    1955    2.6
1955    1955    2.03
2125    1955    2.5
2295    1955    2.32
2465    1955    2.22
2635    1955    2
2805    1955    1.59
2975    1955    2.23
3145    1955    2.18
3315    1955    2.07
3485    1955    2.38
3655    1955    2.48
3825    1955    1.42
85  1785    1.3
255 1785    1.41 
\end{filecontents*}
\begin{tikzpicture}
    \begin{axis}[%
            ,colorbar
            ,view={0}{90}
            ,xmin=0
            ,xmax=3910
            ,ymin=0
            ,ymax=2040
            ,width=391pt
            ,height=204pt
            ,grid=minor
            ,xlabel=Width $b_\mathrm{frame}$ in \si{\milli\metre}
            ,ylabel=Height $h_\mathrm{frame}$ in \si{\milli\metre}
,minor xtick={0,170,...,5000}
,minor ytick={0,170,...,5000}
,xtick={0,500,...,5000}
,ytick={0,500,...,5000}
,tick style={black}
%,x tick label style={rotate=90}
        ]
\addplot3[surf, shader=interp] file {data.dat};
\addplot3[surf] coordinates {(0, 0, 0) (0, 0, 3)};
    \end{axis}
\node[xshift=2mm, yshift=4.5mm, rotate=90] at (current bounding box.east){Speed $v$ in \si{\metre\per\second}};
\end{tikzpicture}
\end{document}

在此輸入影像描述

相關內容