I'm having trouble plotting a secant function. I get Dimension too large error but I can't solve it.
\documentclass{article}
\usepackage{amsmath}
\usepackage{yhmath}
\usepackage[a4paper]{geometry}
\usepackage{enumitem}
\usepackage{amssymb}
\usepackage{multicol}
\usepackage[spanish]{babel}
\usepackage{hyperref}
\usepackage{imakeidx}
\usepackage{subfiles}
\usepackage{import}
\usepackage{cancel}
\usepackage{tikz}
\usepackage{tikz-network}
\usepackage{arydshln}
\usepackage{pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}
[axis line style = very thick,
ymin=-4,ymax=4,
xmin=-2,xmax=5.5,
xtick=\empty,
ytick=\empty,
extra y ticks={-1,1},
extra x ticks={
-1.5708, %-pi/2
0, %0
1.5708, %pi/2
4.71239}, %3pi/2
extra x tick labels={
$-\frac{\pi}{2}$, %-pi/2
$0$, %0
$\frac{\pi}{2}$, %pi/2
$\frac{3\pi}{2}$}, %3pi/2
every extra x tick/.style={
xticklabel style={anchor=south west},
grid=major,
major grid style={thick,dashed,black}
},
axis lines = center,
xlabel=$x$,ylabel=$y$,
domain=-.5*pi:.5*pi,
samples=200,
]
\addplot [blue,domain=-pi/2:pi/2,ultra thick] {sec(deg(x))};
\addplot [blue, domain=pi/2:3*pi/2,ultra thick] {sec(deg(x))};
%\node at (axis cs:0.2, -0.28) {$O$} ;
%\node at (axis cs:3.14, -0.28) {$\pi$} ;
\addplot[only marks, color=orange] coordinates {(0,1)};
\addplot[only marks, color=orange] coordinates {(0,-1)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
I have read several posts but I can not find what is the problem that makes my code fail. Changing the domain of the function, everything works, but I need to paint that domain.
The error is:
<recently read> \pgf@yy
l.59 \end{axis}
I can't work with sizes bigger than about 19 feet.
Continue and I'll use the largest value I can.