Extreme pgfplots -- 提高 3d 極座標圖解析度並防止“TeX 容量超出”

Extreme pgfplots -- 提高 3d 極座標圖解析度並防止“TeX 容量超出”

所以我有這個描述天線輻射方向圖的 3D 極座標圖,它是用從模擬程式導出的資料產生的。中間的尖峰是輻射圖的主要特徵,但應該更多圓形的

這是因為最大角度解析度為 3 度(x 軸和 y 軸以度為單位)。較小的分辨率(2 或 1 度)會導致TeX capacity exceeded錯誤。

然而,我很樂意只在峰值附近提高分辨率(-15 < phi,theta < 15),但我在處理資料檔案時遇到了困難。

在此輸入影像描述

MWE 如下:

\documentclass{standalone}

\usepackage{pgfplots,siunitx}
\usepgfplotslibrary{dateplot,polar,units,external}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
        colorbar,
        data cs=polar,
        ymin=-50, ymax=50,
        xmin=-50, xmax=50,
        zmin=0, zmax=31,
        xlabel={$\phi$},
        x unit=\si{\degree},
        ylabel={$\theta$},
        y unit=\si{\degree},
        zlabel={Directivity},
        z unit=\si{\dB},        
        point meta min=0, point meta max=31,
        unit vector ratio*=1 1 2,
        z buffer=sort,
        view={45}{30},
        width=20cm
        ]
\addplot3[surf, fill=white, mesh/ordering=y varies, mesh/rows=61] %
table[x index={1},y index={0},z index={2}]{8x8-ful-arr-good-3.txt};
\end{axis}
\end{tikzpicture}
\end{document}

資料檔是:

我正在尋找一種使用 pgfplots 改進所需區域中的繪圖的方法。有沒有辦法合併這兩個文件?

答案1

x filter您可以通過和/或過濾掉不需要的點y filter。為了保持網格結構完整,您必須遵守以下兩點:

  1. 確保您分配unbounded coords=jump
  2. 確保應該丟棄的點收到“nan”(並且不是空值)。

違反任何這些條款都會破壞網格結構。

這是我得到的:

\documentclass[border=5mm]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
        data cs=polar,
       % ymin=-180, ymax=180,
       % xmin=-180, xmax=180,
       % zmin=-20, zmax=11,
       % unit vector ratio*=1 1 10,
        z buffer=sort,
        view={45}{30},
        width=15cm,
        x filter/.code={%
            % PHI:
            \ifdim-15pt>#1pt
                \def\pgfmathresult{nan}%
            \fi
        },
        y filter/.code={%
            % THETA
            \ifdim#1pt>15pt
                \def\pgfmathresult{nan}%
            \fi
        },
        unbounded coords=jump,
        ]
\addplot3[surf, fill=white, mesh/ordering=y varies, mesh/rows=37] table[x index={1},y index={0},z index={2}]{polar.dat};
\end{axis}
\end{tikzpicture}
\end{document}

在此輸入影像描述

一些注意事項:

  1. 我使用了你的數據文件Pgfplots 閉合極座標圖中的路徑
  2. x filter似乎沒有效果...您可能想根據您的資料檔案調整這些內容。
  3. 我的範例中的過濾器透過 TeX 原語工作,即透過\ifdim<dimension1> <operation> <dimension2>.由於這種情況下的數字沒有維度,我必須人為地附加“pt”。這種方法的精確度有限,數字範圍< 16384,但它適用於這張圖片。
  4. \if<condition> \else \fi是條件語句的 TeX 原語,並\def\pgfmathresult{nan}以「nan」覆寫結果。
  5. 某些切片中有一個洞,我懷疑你的條件「(-15 < phi, theta < 15)」可能需要一些修改——要么是因為我使用了錯誤的數據文件,要么是因為它確實需要不同的參數。

參考資料:請參閱 pgfplots 手冊,尤其是unbounded coords.

相關內容