TeX - LaTeX Asked by u49K3df2 on February 9, 2021
I want to draw a vertical dashed line (1,0) — (1,3) but it does not work..
documentclass{article}
usepackage{tikz}
usetikzlibrary{arrows}
usepackage{pgfplots}
usepackage[utf8]{inputenc}
pgfplotsset{width=7cm,compat=1.9}
begin{document}
begin{tikzpicture}
begin{axis}[
axis x line=center,
axis y line=center,
xlabel = {$alpha$},
ylabel = {$h(alpha)$},
xlabel style={ right},
ylabel style={above },
]
addplot [
domain=-1.5:1.5,
samples=1000,
color=blue,
]
{1*x + 1*x^2};
end{axis}
draw[dashed] (1,0) -- (1,3);
end{tikzpicture}
end{document}
Put this inside the axis
environment:
draw [dotted,->] (axis cs:1,0) -- (axis cs:1,3);
Answered by Ivan on February 9, 2021
With use of the recent LaTeX installation and recent version pgfplots
package (yours is very old, it is time to upgrade it):
documentclass{article}
usepackage{pgfplots} % it loads tikz too
usetikzlibrary{arrows}
pgfplotsset{width=7cm,compat=1.17} % <----
begin{document}
begin{tikzpicture}
begin{axis}[
axis lines=center,
xlabel = {$alpha$},
ylabel = {$h(alpha)$},
xlabel style={ right},
ylabel style={above },
]
addplot +[domain=-1.5:1.5, samples=100, thick, no marks]
{1*x + 1*x^2};
draw[dashed] (1,0) -- (1,3); % <---
end{axis}
end{tikzpicture}
end{document}
Answered by Zarko on February 9, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP