使用 PSTricks 繪製正餘弦函數圖

使用 PSTricks 繪製正餘弦函數圖

我在 Miktex+Texmaker 中有以下程式碼,使用設定 LaTeX+dvips+ps2pdf+View PDF:

下面第一張圖(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}

然而,下面的第二張圖(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)請幫我繪製和的第二張圖\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}

相關內容