-1

I have the following codes in Miktex+Texmaker using the configurations LaTeX+dvips+ps2pdf+View PDF:

The following first figure (fig:cosine-plot) appears clearly:

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

However, the following second figure (Fig-sin-cos) doesn't appear on the compilation.

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

Please help me plot the second Graphs of \sin(x) and \cos(x).

The related question has the solutions here.

3
  • 2
    this is identical to your last question. where you had sqrt(x) instead of x sqrt and now you have cos(x) instead of x cos or as shown in the other answer to your last question you can use the pstricks algebraic function parser, or (like most people) you could use pdflatex instead of latex/dvips/pstopdf and use pgfplots rather than pstricks Jan 31 at 16:44
  • @DavidCarlisle: you can also use xelatex or better lualatex to get direct the pdf output.
    – user187802
    Feb 1 at 7:35
  • @user187802 yes true Feb 1 at 8:32

1 Answer 1

2

You need the option algebraic, you can do it globaly with \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}

Not the answer you're looking for? Browse other questions tagged .