修剪 3d pgfplots 圖表頂部過多的空白

修剪 3d pgfplots 圖表頂部過多的空白

使用中的數據這個文件,我有以下情節:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{savetrees}

\begin{document}

\begin{figure}[b]
    \centering
    \begin{tikzpicture}
        \begin{axis}[
            width=\linewidth,
            height=0.9\textheight,
            view = {95}{40},
            zmin = 0,
            restrict z to domain = 1:,
            axis x line = left,
            axis y line = left,
            axis z line = right,
        ]
            \addplot3 [draw=black, mark=none] table {biomass.txt};
        \end{axis}
    \end{tikzpicture}
    \caption{Caption}
\end{figure}

\end{document}

給予

在此輸入影像描述

我想修剪掉頂部多餘的空白,如下:

在此輸入影像描述

我的猜測是,圖表在頂部添加了額外的空間,以防我想要z周圍都有軸,但即使我不需要左上角的空間,也會顯示額外的空間。

任何幫助表示讚賞。

答案1

使用裁剪似乎是正確的解決方案。另請參閱這個問題關於使用剪輯。

您的 MWE 將變為:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{savetrees}

\begin{document}

\begin{figure}[b]
    \centering
    \begin{tikzpicture}
    \clip (-0.5, -1) rectangle (15, 19)
        \begin{axis}[
            width=\linewidth,
            height=0.9\textheight,
            view = {95}{40},
            zmin = 0,
            restrict z to domain = 1:,
            axis x line = left,
            axis y line = left,
            axis z line = right,
        ]
            \addplot3 [draw=black, mark=none] table {biomass.txt};
        \end{axis}
    \end{tikzpicture}
    \caption{Caption}
\end{figure}

\end{document}

您必須找到正確的剪輯參數,但之後它應該會像魅力一樣工作。如果您想將整體移得更高一點,請考慮使用負 vspace (\vspace{-10mm})。

相關內容