-
Notifications
You must be signed in to change notification settings - Fork 3
/
elem-highlight_curve.tex
35 lines (32 loc) · 1.01 KB
/
elem-highlight_curve.tex
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
% https://latexdraw.com/how-to-highlight-parts-of-a-function-and-change-the-background-color-in-latex-using-tikz/
% arr: indenting code; add comments
\documentclass[dvipsnames]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat = newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
xmin = 0, xmax = 7,
ymin = -20, ymax = 20,
width = 8cm,
height = 6.5cm,
xtick distance = 1,
ytick distance = 4,
smooth,
xlabel=$x$-axis,
ylabel=$y$-axis,
set layers,
]
% plot background yellowish
\begin{pgfonlayer}{axis background}
\fill [yellow!10] (0,-20) rectangle (7,20);
\end{pgfonlayer}
% superposing three curves with different thickness and colors
\addplot[Green!20, domain = 0:7, line width=4mm] {(x-1)*(x-3)^2*(x-6)}; % very thick curve
\addplot[Green!30, domain = 0:7, line width=2mm] {(x-1)*(x-3)^2*(x-6)}; % thick curve
\addplot[Green, domain = 0:7, thick] {(x-1)*(x-3)^2*(x-6)}; % thin curve
\end{axis}
\end{tikzpicture}
\end{document}