I have a problem. I have a graph, and I must paste a random number in every vertex of this graph. Vertices have coordinates.

A part of code :

\foreach \pos/\name in {{(0,0)/a}, {(1,-1)/b}, {(1.5,-2)/c},
                                {(1.3,-2.5)/d}, {(0.6,-2.5)/e}, {(2,-2.66)/f}, 
            \node[circle,fill=black!25,minimum size=15pt,inner sep=0pt] (\name) at \pos {\pgfmathsetmacro{rand}};
  • It's really hard to understand what you mean. Do you want to draw a bicycle? Ared the "some coordinates" also random or are they defined? It would be really helpful if you could provide us with something that you already tried, and ask for specific questions on your example. – Habi Nov 18 '14 at 12:19
  • I guess by "cycle" you mean a "loop". I also guess you are using some drawing program. How you store coordinates will depend very much on which program you are using. Please post more information, preferably containing a small document with your set-up, cf. minimal working example (MWE) – Andrew Swann Nov 18 '14 at 12:36
  • ok, thanks for notes, I've added some information. – just a man Nov 18 '14 at 13:00

Here is a solution:

\pgfmathsetseed{\pdfuniformdeviate 10000000} % new seed at each compilation
  \foreach \pos/\name in {
  } {
    \pgfset{number format/.cd,fixed}
    \node[circle,fill=black!25,minimum size=15pt,inner sep=0pt,font=\tiny]
    (\name) at \pos {\pgfmathprintnumber{\myvalue}};
| improve this answer | |
  • Oh, thanks for showing us the \pgfmathsetseed command. – Sigur Oct 22 '18 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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