装饰 pgfplots 网格

装饰 pgfplots 网格

为了解决这个问题我正在尝试看看是否可以通过绘制许多圆或半径由 确定的矩形来装饰网格图\pgfplotspointmetatransformed。但我似乎无法装饰网格图。下面的 MWE 包含三次尝试,全部被注释掉,因为所有尝试都失败了! Package PGF Error: I cannot decorate an empty path.。我正在使用pgfplots 2011/12/29 v1.5.1 (git show 1.5.1-4-g53e640f )tikz 2010/10/13 v2.10 (rcs-revision 1.76)

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.shapes}
\pgfplotsset{compat=1.5}%
\begin{document}%
\begin{tikzpicture}
\begin{axis}
% all three attemps fail with:
% ! Package PGF Error: I cannot decorate an empty path.
%\addplot[mesh,point meta=y,decorate,decoration={triangles}] {x^2};
%\addplot[mesh,point meta=y,every path/.append style={decorate,decoration={triangles}}] {x^2};
%\addplot[mesh,point meta=y,every path/.append style={postaction={decorate},decoration={triangles}}] {x^2};
\end{axis}
\end{tikzpicture}%
\end{document}
  • 我该如何装饰网格图?

答案1

无需装饰图。选项only marks将为您绘制三角形。

\documentclass[tikz,border=9]{standalone}
\usepackage{pgfplots}
\begin{document}%
    \begin{tikzpicture}
        \begin{axis}
            \addplot[scatter,scatter src=y,
                     only marks,
                     mark=triangle*,
                     mark options={scale=(1+\pgfplotspointmetatransformed/100)},
                     samples=200
                    ] {x^3-15*x};
        \end{axis}
    \end{tikzpicture}%
\end{document}

相关内容