3

I think I know how to add dashed asymptotes \draw [dashed] (1st pt) -- (2nd pt) but before I have to remove the default asymptotes. Maybe one way is to truncate the domain in the neighborhoods of the asymptotes in order to have a domain composed of (in this case) 5 smaller sets, but I don't know how to do it. Also maybe there is a simpler solution.

enter image description here

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{geometry}
\geometry{
   showframe, % mostra l'area di lavoro
   a4paper,top=2cm,bottom=3cm,left=2.5cm,right=3cm,% per regolare i bordi a piacimento
   heightrounded,bindingoffset=5mm}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
ymin=-6,ymax=6,
xmin=-6,xmax=6,
xtick=\empty,
ytick=\empty,
extra x ticks={-4.71,-3.14,-1.57,0,1.57,3.14,4.71},
extra x tick labels={$-\frac{3\pi}{2}$,$-\pi$,$-\frac{\pi}{2}$,0,$\frac{\pi}{2}$,$\pi$,$\frac{3\pi}{2}$},
axis lines=center,
xlabel={$x$},
ylabel={$y$},
domain=-1.8*pi:1.8*pi, ]
\addplot [samples=200] {tan(deg(x))};
\end{axis}
\end{tikzpicture}

\end{document}
  • 1
    Use the next option: restrict y to domain=-10:10. It removes the asymptotes. – user91669 Nov 30 '17 at 13:08
  • I did not know about that command! Thanks – sound wave Nov 30 '17 at 13:39
4
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymin=-6,ymax=6,
xmin=-6,xmax=6,
xtick=\empty,
ytick=\empty,
extra x ticks={-4.71,-3.14159,-1.5708,0,1.57,3.14,4.71},
extra x tick labels={$-\frac{3\pi}{2}$,$-\pi$,$-\frac{\pi}{2}$,0,$\frac{\pi}{2}$,$\pi$,$\frac{3\pi}{2}$},
axis lines=center,
xlabel={$x$},
ylabel={$y$},
domain=-1.8*pi:1.8*pi,
samples=1000]
\addplot [dashed] {tan(deg(x))};
\addplot [restrict y to domain=-10:10,line width=1pt] {tan(deg(x))};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.