Graphics, Figures & Tables ⇒ Number Line Help
Number Line Help
I'm completely new to LaTeX and have thrown myself somewhat in the deep end when starting a maths course.
I would like some help creating a number line with another line above it. The higher of the two lines requires dots on either end; one filled and one not. Example attached.
Any pointers would be greatly appreciated. Thanks in advance.
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Number Line Help
Code: Select all
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
x=3mm,
axis y line=none,
axis x line=center,
xtick align=outside,
xtick={-5,0,...,30},
xmin=-7, xmax=33,
ymin=0, ymax=1,
xlabel=$x$,
xlabel style={anchor=north}
]
\addplot [nodes=draw, circle, inner sep=1.5pt]
coordinates {(-5,.1) (25,.1)}
node [fill, at start] {}
node [fill=white] {}
;
\end{axis}
\end{tikzpicture}
\end{document}
\addplot
:Code: Select all
\draw [nodes=draw, circle, inner sep=1.5pt]
(-5,.1) node (filled) [fill] {}
(25,.1) node (open) {}
(filled) -- (open)
;
Number Line Help
Just one more addition I need to may if you wouldn't mind. I need to include a label above the top line as below:
Number Line Help
Code: Select all
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[
dot/.style={draw, fill=#1, circle, inner sep=1.5pt},
filled/.style={dot},
open/.style={dot=white}
]
\begin{axis}[
x=3mm,
axis y line=none,
axis x line=center,
xtick align=outside,
xtick={-5,0,...,30},
xmin=-7, xmax=33,
ymin=0, ymax=1,
xlabel=$x$,
xlabel style={anchor=north}
]
\addplot [black]
coordinates {(-5,.1) (25,.1)}
node [filled, at start] {}
node [open] {}
node [above, midway] {A}
;
\end{axis}
\end{tikzpicture}
\end{document}
Code: Select all
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[
dot/.style={draw, circle, inner sep=1.5pt},
filled/.style={dot, fill},
open/.style={dot}
]
\begin{axis}[
x=3mm,
axis y line=none,
axis x line=center,
xtick align=outside,
xtick={-5,0,...,30},
xmin=-7, xmax=33,
ymin=0, ymax=1,
xlabel=$x$,
xlabel style={anchor=north}
]
\draw
(-5,.1) node [filled] (filled) {}
(25,.1) node [open] (open) {}
(filled) -- node [above] {A} (open)
;
\end{axis}
\end{tikzpicture}
\end{document}