topology-3.tex 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. \newenvironment{customlegend}[1][]{%
  2. \begingroup
  3. % inits/clears the lists (which might be populated from previous
  4. % axes):
  5. \csname pgfplots@init@cleared@structures\endcsname
  6. \pgfplotsset{#1}%
  7. }{%
  8. % draws the legend:
  9. \csname pgfplots@createlegend\endcsname
  10. \endgroup
  11. }%
  12. % makes \addlegendimage available (typically only available within an
  13. % axis environment):
  14. \def\addlegendimage{\csname pgfplots@addlegendimage\endcsname}
  15. %%--------------------------------
  16. % definition to insert numbers
  17. \pgfkeys{/pgfplots/number in legend/.style={%
  18. /pgfplots/legend image code/.code={%
  19. \node at (0.295,-0.0225){#1};
  20. },%
  21. },
  22. }
  23. \pgfdeclarelayer{background}
  24. \pgfdeclarelayer{foreground}
  25. \pgfsetlayers{background,main,foreground}
  26. \begin{tikzpicture}
  27. \tikzstyle{point}=[circle,thick,draw=black,fill=black,inner sep=0pt,minimum width=4pt,minimum height=4pt]
  28. \tikzstyle{smallpoint}=[circle,thick,draw=red,fill=red,inner sep=0pt,minimum width=3pt,minimum height=3pt]
  29. \begin{pgfonlayer}{foreground}
  30. \node (a)[point] at (0,0) {};
  31. \node (b)[point] at (2,0) {};
  32. \node (c)[point] at (3,0.5) {};
  33. \node (d)[point] at (0,3) {};
  34. \node (e)[point] at (2,3) {};
  35. \node (f)[point] at (3,1.5) {};
  36. \node (g)[point] at (2,2.5) {};
  37. \node (h)[point] at (1,1.5) {};
  38. \end{pgfonlayer}
  39. \draw (h.center) -- (e.center) -- (f.center) -- (b.center) -- cycle;
  40. \draw (h.center) -- (f.center);
  41. \draw[green, densely dashed] (a.center) -- (d.center) -- (g.center) -- (c.center) -- cycle;
  42. \draw[green, densely dashed] (a.center) -- (g.center);
  43. \begin{pgfonlayer}{foreground}
  44. \node (x)[point, red,fill=red] at (1.79,0.31) {};
  45. \node (x1)[smallpoint] at (1.2,1.5) {};
  46. \node (x2)[smallpoint] at (1.71,2.56) {};
  47. \node (x3)[smallpoint] at (2.5,1.5) {};
  48. \node (x4)[smallpoint] at (2.72,1.06) {};
  49. \end{pgfonlayer}
  50. \draw[blue, densely dotted] (x.center) -- (x1.center);
  51. \draw[blue, densely dotted] (x.center) -- (x2.center);
  52. \draw[blue, densely dotted] (x.center) -- (x3.center);
  53. \draw[blue, densely dotted] (x.center) -- (x4.center);
  54. \begin{customlegend}[
  55. legend entries={
  56. $T_1$,
  57. $T_2$,
  58. $?$
  59. },
  60. legend style={at={(4.5,3.5)},font=\footnotesize}] % <= to define position and font legend
  61. % the following are the "images" and numbers in the legend
  62. \addlegendimage{black}
  63. \addlegendimage{green,densely dashed}
  64. \addlegendimage{blue, densely dotted}
  65. \end{customlegend}
  66. \end{tikzpicture}