Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following simple example:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}

  \coordinate (a) at (0,0);
  \coordinate (b) at (1,1);
  \coordinate (c) at (2,0);

  \draw (a) -- (b) -- (c);

  \fill (a) circle (2pt);
  \fill (b) circle (2pt);
  \fill (c) circle (2pt);

\end{tikzpicture}
\end{document}

I am interested in improving this code. In particular I would like to avoid the manual drawing of the circles. Have in mind a case where many vertices are involved with many different names.

I know I could replace the fill's with some loop like

  \foreach \i in {a,b,c}
  \fill (\i) circle (2pt);

But I'm interested in more global magic, that is a way to fill a circle (or any other shape) of some fixed radius radius (or dimension) whenever TikZ meets a coordinate.

A bonus would be a solution which can be switched off for certain vertices. I believe the solution is to use style's but I don't know how to do it.

share|improve this question
    
Why don’t you use plot with a plotmark? You could also use the show path construction decoration which allows access to the coordinates. Otherwise you will need to hack TikZ, I guess. :) –  Qrrbrbirlbel Oct 27 '13 at 15:16
    
@Qrrbrbirlbel: I guess the simplest answer is because I don't know these options... plot together with plotmark seems to be a solution. How can I determine the shape /size of the mark? show path construction seems to be an overkill, or simply too complicated... –  Dror Oct 27 '13 at 15:26
add comment

1 Answer

With a plot you can use marks. This allows to use the marks *, x, + and ball. More plot marks can be loaded with the plotmarks library.

Available options are

  • mark,
  • mark repeat,
  • mark phase,
  • mark indices,
  • mark size,
  • the style every mark,
  • mark options (which simply sets every mark) and
  • no marks and no markers (which are the same as mark=none).

and with the plotmarks library

  • mark color (for the other color of the starred half versions),
  • text mark (text used for the text mark),
  • text mark as node and
  • text mark style

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{plotmarks}
\begin{document}
\begin{tikzpicture}[anchor=mid west,
  mark size=+2pt, mark color=blue, text mark=Ti\emph{k}Z, ball color=green]
  \foreach \plm[count=\cnt] in {*, x, +, ball, % always loaded, ball only with TikZ
      -, |, o, asterisk, star, 10-pointed star,
      oplus, oplus*, otimes, otimes*, triangle, triangle*, diamond, diamond*,
      halfdiamond*, halfsquare*, halfsquare right*, halfsquare left*,
      pentagon, pentagon*, Mercedes star, Mercedes star flipped, halfcircle, halfcircle*,
      heart, text}
    \draw[mark options={fill=red}, shift=(down:\cnt/2.5)]
      plot[mark=\plm] coordinates {(0,0) (1,.5) (2,0)} node {\quad\ttfamily\plm};
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.