如何在同一坐标中绘制正弦函数及其反函数的图形?

如何在同一坐标中绘制正弦函数及其反函数的图形?

我尝试使用 tikz 图片绘制此图,但仍然失败。我不知道该怎么做才能绘制此图。我尝试使用这个

\documentclass[10pt]{article}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\definecolor{uuuuuu}{rgb}{0.26666666666666666,0.26666666666666666,0.26666666666666666}
\begin{center}
    \begin{tikzpicture}
    \begin{axis}
    [width=2.3in,
    axis line style = thick,
    ymin=-1.2,ymax=1.2,
    xmin=-2.1,xmax=2.1,
    %clip=false,
    xtick=\empty,
    ytick={-1,0,1},
    extra x ticks={3.14, 6.28},
    extra x tick labels={$\pi$},
    every extra x tick/.style={
        xticklabel style={anchor=north west},
        %       grid=major,
        %       major grid style={dashed,black}
    },
    axis lines = center,
    xlabel=$x$,ylabel=$y$,
    domain=-.5*pi:.5*pi,
    samples=200,]
    \addplot [black, thick] {sin(deg(x))};
    \addplot [domain=-pi/2:pi/2, thick] {sin(x)};
%   \addplot [domain=-1:1, black, thick]  {asin(x)};
    %\addlegendentry{$y=\arcsin(x)$};
    \addplot [domain=-pi/2:pi/2, thick] {x};
    \node at (axis cs:0.2, -0.22) {$O$} ;
    \node at (axis cs:6.48,-0.28)   {$2\pi$};
    \node at (axis cs:-1.57,-0.29)   {$\frac{-\pi}{2}$};
    \node at (axis cs:-3.55,-0.29)   {$-\pi$};
    \node at (axis cs:1.7,-0.29)   {$\frac{\pi}{2}$};
    \node at (axis cs:-6.28,-0.29)   {$-2\pi$};
    %   \node at (axis cs:3.6,-0.9)   {$A$};
    %   \node at (axis cs:5.8,-0.9)   {$B$};
    \end{axis}
    \end{tikzpicture}
 \end{center}
\end{document}

在此处输入图片描述

答案1

首先,你的数字似乎是错误的。这绝对不是一个正弦函数,它只在 -1 和 1 之间振荡。

我相信您正在尝试做的事情可以通过以下方式实现:

\begin{tikzpicture}
\begin{axis}[
        samples=500,
        xtick={-1.57,-1,0,1,1.57},
        xticklabels={$-\pi/2$,-1,0,1,$\pi/2$},
        axis line style = thick,
        axis lines = center,
    ]
    \addplot [blue,domain=-pi/2:pi/2]{sin(deg(x))};
    \addplot [red,domain=-1:1]{asin(x)/180*pi)};
    \addplot [dashed,domain=-pi/2:pi/2]{x};
\end{axis}
\end{tikzpicture}

看起来像这样:

sin(x) 和 arcsin(x)

希望我能帮助你,Cube

相关内容