topology-metric-hausdorff.tex 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. % defining the new dimensions and parameters
  2. \newlength{\hatchspread}
  3. \newlength{\hatchthickness}
  4. \newlength{\hatchshift}
  5. \newcommand{\hatchcolor}{}
  6. % declaring the keys in tikz
  7. \tikzset{hatchspread/.code={\setlength{\hatchspread}{#1}},
  8. hatchthickness/.code={\setlength{\hatchthickness}{#1}},
  9. hatchshift/.code={\setlength{\hatchshift}{#1}},% must be >= 0
  10. hatchcolor/.code={\renewcommand{\hatchcolor}{#1}}}
  11. % setting the default values
  12. \tikzset{hatchspread=6pt,
  13. hatchthickness=0.4pt,
  14. hatchshift=0pt,% must be >= 0
  15. hatchcolor=black}
  16. % declaring the pattern
  17. \pgfdeclarepatternformonly[\hatchspread,\hatchthickness,\hatchshift,\hatchcolor]% variables
  18. {custom north west lines}% name
  19. {\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner
  20. {\pgfqpoint{\dimexpr\hatchspread+2\hatchthickness}{\dimexpr\hatchspread+2\hatchthickness}}% upper right corner
  21. {\pgfqpoint{\dimexpr\hatchspread}{\dimexpr\hatchspread}}% tile size
  22. {% shape description
  23. \pgfsetlinewidth{\hatchthickness}
  24. \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\hatchspread+\hatchshift}}
  25. \pgfpathlineto{\pgfqpoint{\dimexpr\hatchspread+0.15pt+\hatchshift}{-0.15pt}}
  26. \ifdim \hatchshift > 0pt
  27. \pgfpathmoveto{\pgfqpoint{0pt}{\hatchshift}}
  28. \pgfpathlineto{\pgfqpoint{\dimexpr0.15pt+\hatchshift}{-0.15pt}}
  29. \fi
  30. \pgfsetstrokecolor{\hatchcolor}
  31. % \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way
  32. \pgfusepath{stroke}
  33. }
  34. \begin{tikzpicture}
  35. \begin{axis}[
  36. legend pos=south west,
  37. axis x line=middle,
  38. axis y line=middle,
  39. %grid = major,
  40. %width=9cm,
  41. %height=4.5cm,
  42. grid style={dashed, gray!30},
  43. xmin=-1, % start the diagram at this x-coordinate
  44. xmax= 6, % end the diagram at this x-coordinate
  45. ymin=-0.25, % start the diagram at this y-coordinate
  46. ymax= 5, % end the diagram at this y-coordinate
  47. axis background/.style={fill=white},
  48. xlabel=$X_1$,
  49. ylabel=$X_2$,
  50. %xticklabels={,,},
  51. %yticklabels={,,},
  52. %xtick={-1,0,1,2,3,4,5},
  53. %ytick={-1,0,1,2,3,4,5},
  54. ticks=none,
  55. %tick align=outside,
  56. enlargelimits=true,
  57. tension=0.08]
  58. \addplot[hatchcolor=red,mark=none, pattern=custom north west lines, draw=none] coordinates {(0.5, 0) (0.5,5) (1.5,5) (1.5,0) };
  59. \addplot[red,mark=none, thick] coordinates {(0.5, 0) (0.5,5)};
  60. \addplot[red,mark=none, thick] coordinates {(1.5, 0) (1.5,5)};
  61. \addplot[hatchcolor=red,mark=none, pattern=custom north west lines, draw=none] coordinates {(4.5, 0) (4.5,5) (5.5,5) (5.5,0) };
  62. \addplot[red,mark=none, thick] coordinates {(4.5, 0) (4.5,5)};
  63. \addplot[red,mark=none, thick] coordinates {(5.5, 0) (5.5,5)};
  64. \addplot[mark=none, dashed] coordinates {(1, 0) (1,3)};
  65. \addplot[mark=none, dashed] coordinates {(5, 0) (5,3)};
  66. \addplot[mark=x] coordinates {(1, 3)};
  67. \addplot[mark=x] coordinates {(5, 3)};
  68. \node at (axis cs:1,3) [anchor=north west] {$(x_1, y_1)$};
  69. \node at (axis cs:5,3) [anchor=north west] {$(x_2, y_2)$};
  70. \node at (axis cs:1,0) [anchor=north] {$x_1$};
  71. \node at (axis cs:5,0) [anchor=north] {$x_2$};
  72. \node[red] at (axis cs:1,-0.3) [anchor=north] {$U_1 \times X_2$};
  73. \node[red] at (axis cs:5,-0.3) [anchor=north] {$U_2 \times X_2$};
  74. \end{axis}
  75. \end{tikzpicture}