PSTricks を使用して sin-cos 関数のグラフをプロットする

PSTricks を使用して sin-cos 関数のグラフをプロットする

LaTeX+dvips+ps2pdf+View PDF 構成を使用して、Miktex+Texmaker に次のコードがあります。

次の最初の図(fig:cosine-plot)がはっきりと現れます。

\begin{figure}[H]
  \centering
  \begin{pspicture}(-2,-1.5)(4,1.5)
    \psaxes{->}(0,0)(-2,-1.5)(4,1.5)[$x$,0][$y$,90]
    \psplot[linecolor=red, algebraic]{-2}{3.5}{cos(x)}
  \end{pspicture}
  \caption{Plot of $\cos(x)$}
  \label{fig:cosine-plot}
\end{figure}

しかし、次の2番目の図(Fig-sin-cos)はコンパイル時には表示されません。

\begin{figure}[H]
  \centering
  \begin{pspicture}(-2,-1.5)(4,1.5)
    \psgrid[griddots=10,gridlabels=0pt, subgriddiv=0, gridcolor=black!20]
    \psaxes{->}(0,0)(-2,-1.5)(4,1.5)
    \psplot[linecolor=blue]{-2}{4}{sin(x)}
    \psplot[linecolor=red]{-2}{4}{cos(x)}
  \end{pspicture}
  \caption{Graphs of $\sin(x)$ and $\cos(x)$}\label{Fig-sin-cos}
\end{figure}

\sin(x)との 2 番目のグラフをプロットするのを手伝ってください\cos(x)

関連する質問には解決策がありますここ

答え1

オプションが必要ですalgebraic。グローバルに実行できます。\psset{algebraic}

\documentclass[11pt]{article} 
\usepackage{pst-all}
\begin{document}
 
\psset{algebraic} %change
\begin{figure}[ht] 
\centering 
\begin{pspicture}(-2,-1.5)(4,1.5) 
\psgrid[griddots=10,gridlabels=0pt, subgriddiv=0, gridcolor=black!20] 
\psaxes{->}(0,0)(-2,-1.5)(4,1.5) 
\psplot[linecolor=blue]{-2}{4}{sin(x)} 
\psplot[linecolor=red]{-2}{4}{cos(x)} 
\end{pspicture} 
\caption{Graphs of $\sin(x)$ and $\cos(x)$}\label{Fig-sin-cos} 
\end{figure}

\end{document}

関連情報