尺寸太大绘图秒

尺寸太大绘图秒

我在绘制割线函数时遇到了麻烦。我得到尺寸太大错误,但我无法解决。

\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}

我读了几篇文章,但还是找不到导致我的代码失败的问题。更改函数的域,一切正常,但我需要绘制该域。

错误是:

<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.

答案1

你可以restrict y to domain这样使用:

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis line style=very thick,
xmin=-2, xmax=5.5,
ymin=-4, ymax=4,
xtick={-pi/2, 0, pi/2, 3*pi/2},
ytick={-1,1},
xticklabels={$-\frac{\pi}{2}$, 0, $\frac{\pi}{2}$, $\frac{3\pi}{2}$}, 
xticklabel style={anchor=north west},
xmajorgrids=true,
major grid style={thick, dashed, black},
axis lines=center,
xlabel=$x$, ylabel=$y$,
restrict y to domain=-10:10,
]
\addplot[blue, domain=-pi/2:3*pi/2, ultra thick, samples=100, smooth] {sec(deg(x))};
\addplot[only marks, color=orange, forget plot] coordinates {(0,1) (0,-1)};
\end{axis}
\end{tikzpicture}
\end{document}

三角函数的图

相关内容