Biểu diễn tập hợp trên trục số

Lượt xem: 67

Description

Biểu diễn tập hợp trên trục số chắc chắn là việc đơn giản. Bạn có thể dùng lệnh vẽ thông thường, hoặc dùng thư viên trang trí decorations.markings

Mã TikZ

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture
}
% Vẽ [0,3) bằng thư viện calc
\draw[thick,->,>=stealth] (-2,0)--
(0,0) node[scale=1.5]{\bf [} node[below=6pt]{$0$}--
(3,0) node[scale=1.5]{\bf )} node[below=6pt]{$3$}--(5.2,0);
\foreach \i in {1,...,10}
        \draw ($(0,0)-(.2*\i,0)$) node[blue,scale=.6]{/};
\foreach \i in {1,...,10}
        \draw ($(3,0)+(.2*\i,0)$) node[blue,scale=.6]{/};
\end{tikzpicture}

\begin{tikzpicture
}
% Vẽ [0,3) bằng thư viện decorations.markings
\draw[thick,->,>=stealth] (-2,0)--
(0,0) node[scale=1.5]{\bf [} node[below=6pt]{$0$}--
(3,0) node[scale=1.5]{\bf )} node[below=6pt]{$3$
}--(5.2,0);

% Đánh dấu như ý
\begin{scope}[decoration={markings,
    mark=between positions 0 and 1 step 1mm
    with {\draw[blue!50
] (60:3pt)--(240:3pt);}
}
]
\draw[postaction={decorate}] (3.1,0) -- (5,0) (-2,0)--(-.1,0);
\end{scope}
\end{tikzpicture}

\begin{tikzpicture
}
% Vẽ (1,4] bằng thư viện calc
\draw[thick] (-2,0)--
(1,0) node[scale=1.5]{\bf (} node[below=6pt]{$1$}--
(4,0) node[scale=1.5]{\bf ]}node[below=6pt]{$4$}--(5,0);

\foreach \i in {1,...,15}
\draw ($(1,0)-(.2*\i,0)$) node[magenta,scale=.6,rotate=60]{/};
\foreach \i in {1,...,5}
\draw ($(4,0)+(.2*\i,0)$) node[magenta,scale=.6,rotate=60]{/};
\end{tikzpicture}

\begin{tikzpicture
}
% Vẽ (1,4] bằng thư viện decorations.markings
\draw[thick,->,>=stealth] (-2,0)--
(1,0) node[scale=1.5]{\bf (} node[below=6pt]{$1$}--
(4,0) node[scale=1.5]{\bf ]}node[below=6pt]{$4$
}--(5.2,0);

% Đánh dấu như ý
\begin{scope}[decoration={markings,
    mark=between positions 0 and 1 step 1mm
    with {\draw[red
] (120:3pt)--(-60:3pt);}
}
]
\draw[postaction={decorate}] (-2,0)--(.9,0) (4,0)--(5,0);
\end{scope}
\end{tikzpicture}

\begin{tikzpicture
}
% Vẽ [0,2) giao (1,4] bằng thư viện calc
\draw[thick,->,>=stealth] (-2,0)--
(0,0) node[scale=1.5]{\bf [} node[below=6pt]{$0$}--
(1,0) node[scale=1.5]{\bf (} node[below=6pt]{$1$}--
(3,0) node[scale=1.5]{\bf )} node[below=6pt]{$3$}--
(4,0) node[scale=1.5]{\bf ]}node[below=6pt]{$4$}--(5.2,0);

\foreach \i in {1,...,10}
\draw ($(0,0)-(.2*\i,0)$) node[blue,scale=.6]{/};
\foreach \i in {1,...,10}
\draw ($(3,0)+(.2*\i,0)$) node[blue,scale=.6]{/};

\draw[thick] (-2,0)--(1,0) node[scale=1.5]{\bf (} node[below=6pt]{$1$}--(4,0) node[scale=1.5]{\bf ]}node[below=6pt]{$4$}--(5,0);

\foreach \i in {1,...,15}
\draw ($(1,0)-(.2*\i,0)$) node[magenta,scale=.6,rotate=60]{/};
\foreach \i in {1,...,5}
\draw ($(4,0)+(.2*\i,0)$) node[magenta,scale=.6,rotate=60]{/};
\end{tikzpicture}

\begin{tikzpicture
}
% Vẽ [0,2) giao (1,4] bằng thư viện decorations.markings
\draw[thick,->,>=stealth] (-2,0)--
(0,0) node[scale=1.5]{\bf [} node[below=6pt]{$0$}--
(1,0) node[scale=1.5]{\bf (} node[below=6pt]{$1$}--
(3,0) node[scale=1.5]{\bf )} node[below=6pt]{$3$}--
(4,0) node[scale=1.5]{\bf ]}node[below=6pt]{$4$}--(5.2,0);

\begin{scope}[decoration={markings,
    mark=between positions 0 and 1 step 1mm
    with {\draw[blue!50
] (60:3pt)--(240:3pt);}
}
]
\draw[postaction={decorate}] (3.1,0) -- (5,0) (-2,0)--(-.1,0);
\end{scope}

\begin{scope}[decoration={markings,
    mark=between positions 0 and 1 step 1.2mm
    with {\draw[red
] (120:3pt)--(-60:3pt);}
}
]
\draw[postaction={decorate}] (-2,0)--(.9,0) (4,0)--(5,0);
\end{scope}
\end{tikzpicture}
\end{document
}