TeX - LaTeX Asked by xyz04 on June 29, 2021
I am trying to graph the following graph and so far I only have code to graph the parabola, could someone help me graph the dashed horizontal and vertical lines.
begin{tikzpicture}
begin{axis}[
axis lines = middle,
xlabel = $x$,
ylabel = {$f(x)$},
yticklabels=empty,
xticklabels=empty,
]
addplot [
domain=0:10,
samples=100,
color=red,
]
{x^2};
end{axis}
end{tikzpicture}
You can insert function equation, which you like to draw, directly to addplot
command, for example:
addplot +[ultra thick, color=purple, domain=0:2] {x^2};
or define function in `axis options as is done in MWE (Minimal Working Example) below.
Point on function curve you can define as (<x>,{f(x){)
or you calculate manually or use in your case select x=1
where f(x) = (x^2)
is 1 (as is used in MWE below.
MWE should work also with older version of pgfplots
, but not the oldest as compat=v1.11
.
documentclass[border=3.141592]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.18}
begin{document}
begin{tikzpicture}
begin{axis}[
declare function = {f(x)=(x)^2);},
axis lines=left,
xlabel = $x$,
ylabel = $f(x)$,
xmin=0, xmax=2.2, xtick=empty,
ymin=0, ymax=4.4, ytick=empty,
domain=0:2,
no marks,
every axis plot post/.append style={ultra thick, color=magenta,},
]
addplot {f(x)} node[right,text=black] {$x^2$};
draw[dashed] (0,1) -- (1,1) node[above left] {$b$}
node[below right] {$a$}
-- (1,0);
end{axis}
end{tikzpicture}
end{document}
Correct answer by Zarko on June 29, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP