5

In my quest to solve this question I'm trying to see if I can decorate a mesh-plot by drawing many circles or maybe rectangles with a radius determined by \pgfplotspointmetatransformed. But I can't seem to decorate a mesh-plot. The MWE below contains three tries, all commented out, because all fail with ! Package PGF Error: I cannot decorate an empty path.. I'm using pgfplots 2011/12/29 v1.5.1 (git show 1.5.1-4-g53e640f ) and 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}
  • How do I decorate a mesh-plot?
gerrit
  • 5,165
  • I'm not exactly sure how this is going to solve the problem of the joins in your other question: The size of the circles would still change discretely, so wouldn't the result still be the same as when using line cap=round with straight line segments. – Jake May 31 '12 at 10:22
  • Right, circles would not be the right way to go. But rectangles would? In my understanding, decorations work on a local coordinate system where x is defined along the decorated line and y perpendicular to it, so a rectangle would actually consist of two parallel and two perpendicular line-segments, if I'm not mistaken. – gerrit May 31 '12 at 12:04
  • Yes, that's right, but then the joins would end up looking like the second example in my answer, with line cap=rect. You'd need to do something like find half the angle between two consecutive line segments. The problem is related to TikZ: changing colour of a path half way along. – Jake May 31 '12 at 12:24
  • Mesh plots in pgfplots use the pgf basic layer engine... perhaps this fools the decoration lib (which is based on the tikz frontend if I am not mistaken). – Christian Feuersänger Jun 02 '12 at 19:42

1 Answers1

3

One does not need to decorate a plot. The option only marks will draw triangles for you.

\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}

Symbol 1
  • 36,855