New answer
Paul Gaborit points out that the pgfmanual
specifically mentions that pgf
commands such as \pgfuseplotmark
should not be used in situation, such as a node
, where text is expected. Rather they should be in a pgfpicture
(or tikzpicture
) environment.
One (ugly) work around to your approach is then to write the node argument in pgfpicture
environment:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\begin{document}
\begin{tikzpicture}
\draw (-1,0) -- ++(2,0);
\draw (0,-1) -- ++(0,2);
\node[mark size=5pt,color=blue,draw] at (0,0) {%
\begin{pgfpicture}
\pgfuseplotmark{triangle*}
\end{pgfpicture}%
};
\end{tikzpicture}
\end{document}
I have drawn a rectangle around the node to show the spacing, compare with bad spacing demonstrated in the original answer below.
Better is to use the mark mechanism as intend in a plot of just one point:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\begin{document}
\begin{tikzpicture}
\draw (-1,0) -- ++(2,0);
\draw (0,-1) -- ++(0,2);
\draw[color=blue] plot[mark=triangle*,mark size=5pt] (0,0);
\end{tikzpicture}
\end{document}
In your code this would give
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- ++(0,-3);
\draw (5cm,0) -- ++(0,-3);
\draw (10cm,0) -- ++(0,-3);
\draw (0,-1)--(10,-1);
\draw[color=red] plot[mark=*,mark size=3pt] (0,-1);
\draw[color=blue] plot[mark=triangle*,mark size=5pt] (5cm,-1);
\draw[color=olive] plot[mark=square*,mark size=4pt] (10cm,-1);
\draw[mark=*,mark size=3pt,mark options={color=olive}] plot coordinates {(0,-2)}
-- plot[mark=triangle*,mark options={color=blue}] coordinates {(5cm,-2)}
-- plot[mark=square*,mark size=4pt,mark options={color=red}] coordinates {(10cm,-2)};
\end{tikzpicture}
\end{document}
Original answer
Most of the plot mark definitions have an error in them with newlines not commented out. For example the triangle*
is defined as:
\pgfdeclareplotmark{triangle*}
{%
\pgfpathmoveto{\pgfqpoint{0pt}{\pgfplotmarksize}}
\pgfpathlineto{\pgfqpointpolar{-30}{\pgfplotmarksize}}
\pgfpathlineto{\pgfqpointpolar{-150}{\pgfplotmarksize}}
\pgfpathclose
\pgfusepathqfillstroke
}
Lines 3, 4 and 5 do not have the newline escaped and so insert a space in to the output, as you can see by drawing the box around the node:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- ++(0,-2);
\node[mark size=5pt,color=blue,draw] at (0,-1) {\pgfuseplotmark{triangle*}};
\end{tikzpicture}
\end{document}
Correcting these definitions, mostly found in pgflibraryplotmarks.code.tex
gives in the original example:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{plotmarks}
\begin{document}
\begin{tikzpicture}
\pgfdeclareplotmark{triangle*}
{%
\pgfpathmoveto{\pgfqpoint{0pt}{\pgfplotmarksize}}%
\pgfpathlineto{\pgfqpointpolar{-30}{\pgfplotmarksize}}%
\pgfpathlineto{\pgfqpointpolar{-150}{\pgfplotmarksize}}%
\pgfpathclose
\pgfusepathqfillstroke
}
\pgfdeclareplotmark{*}
{%
\pgfpathcircle{\pgfpointorigin}{\pgfplotmarksize}%
\pgfusepathqfillstroke
}
\draw (0,0) -- ++(0,-3);
\draw (5cm,0) -- ++(0,-3);
\draw (10cm,0) -- ++(0,-3);
\draw (0,-1)--(10,-1);
\node[mark size=3pt,color=red] at (0,-1) {\pgfuseplotmark{*}};
\node[mark size=5pt,color=blue] at (5cm,-1) {\pgfuseplotmark{triangle*}};
\node[mark size=4pt,color=olive] at (10cm,-1) {\pgfuseplotmark{square*}};
\draw[mark=*,mark size=3pt,mark options={color=olive}] plot
coordinates {(0,-2)}
-- plot[mark=triangle*,mark options={color=blue}] coordinates {(5cm,-2)}
-- plot[mark=square*,mark size=4pt,mark options={color=red}]
coordinates {(10cm,-2)};
\end{tikzpicture}
\end{document}
I have added vertical lines to show the alignment.