4

I am looking to get help to plot tangent function. I find TikZ insufficient capability on TeXShop.

I am thinking about PSTricks and TeXShop. Is there any useful documentation or tutorial on packages involved to start plotting math trig function plots.

mark
  • 431

3 Answers3

3

Have a look at the pst-plot package- the following example is taken from page 28 of the documentation

enter image description here

\documentclass{article}

\usepackage{pst-plot}

\begin{document}

\begin{pspicture}(-6.5,-4)(6.5,7.5)
    \psaxes[trigLabelBase=2,dx=\psPiH,xunit=\psPi,trigLabels]%
        {->}(0,0)(-1.7,-3.5)(1.77,6.5)[$x$,0][$y$,90]
    \psset{algebraic=true}
    \psplot[yMaxValue=6,yMinValue=-3,linewidth=1.6pt,plotpoints=2000,
        linecolor=red]{-4.55}{4.55}{tan(x)}
\end{pspicture}

\end{document}
cmhughes
  • 100,947
  • I have some issues compiling to pdf file./article.tex:24: Undefined control sequence. \c@lor@to@ps

    l.24 {->}(0,0)(-1.7,-3.5)(1.77,6.5)[$x$,0][$y$,90]

    – mark Aug 09 '12 at 03:49
  • How do you compile it from source .tex code to .pdf on TeXShop.Any settings on TeXShop I use LateX but I cannot see the desired graphics. I am new to PS tricks although I have used tikz for diagrams. – mark Aug 09 '12 at 03:56
  • @mark If you are using PSTricks you need to compile via "LaTeX=>PS=>PDF". PSTricks doesn't work with pdflatex directly. – percusse Aug 09 '12 at 10:34
  • 1
    or use xelatex instead of pdflatex –  Aug 09 '12 at 14:48
  • 1
    @mark The question I linked to in my comment to your question shows you how to run the code in TeXShop. – Alan Munn Aug 09 '12 at 16:37
  • Here is my first lesson code. pstlesson1.tex \documentclass{article} \usepackage{pstricks} \usepackage{pstricks-add}

    \begin{document}

    \begin{figure} \begin{pspicture}(4,5) \psgrid \psframe(0.7,2)(3.3,3) \rput(2,2.5){First Example} \end{pspicture} \end{figure} \end{document}

    – mark Aug 10 '12 at 01:29
  • I tried the above code to try to plot tangent code. It does not work. I see line 13 that package xkeyval/pstlesson1.tex:13: Package xkeyval Error: yMinValue' undefined in families ,pstricks,pst-plot,pst-node,pst-3d,pstricks-add'. – mark Aug 10 '12 at 06:43
  • The axis labels like '-3pi/2' appear horizontally and vertically like 6. However, no axes. No tangent curves. I need help to compile this .Thanks – mark Aug 10 '12 at 06:46
  • @mark: if yMinValue is unknown then you have to update your files, see http://texnik.dante.de/ –  Aug 10 '12 at 07:20
  • I am downloading the package TDS. The next step is how to install this set of macros. – mark Aug 11 '12 at 03:22
2

see http://tug.org/PSTricks/main.cgi?file=pdf/pdfoutput#TS for configuring TeXShop for using latex->dvips->ps2pdf

Alternetively use

\usepackage[pdf]{pstricks}

and run your document with pdflatex -shell-escape. The above page show how shell-escape can be enabled.

  • Apart from the fact that the linked image shows the German localisation of TeXShop, it's not terribly helpful: the issue is not setting up TeXShop to use latex->divps->ps2pdf (which it is set up to do out of the box) but how to tell TeXShop to do that for a particular document. See How to run PSTricks in TeXShop. – Alan Munn Aug 09 '12 at 16:42
  • Does that mean I removed the 'file-line error' statements in the window: Latex(default:pdflatex). – mark Aug 10 '12 at 06:32
0

Another method, compile it with pdflatex --shell-escape filename.

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents*}{dummy.tex}
\documentclass[border=12pt,pstricks]{standalone}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-6.5,-4)(6.5,7.5)
    \psaxes[trigLabelBase=2,dx=\psPiH,xunit=\psPi,trigLabels]%
        {->}(0,0)(-1.7,-3.5)(1.77,6.5)[$x$,0][$y$,90]
    \psset{algebraic=true}
    \psplot[yMaxValue=6,yMinValue=-3,linewidth=1.6pt,plotpoints=2000,
        linecolor=red]{-4.55}{4.55}{tan(x)}
\end{pspicture}
\end{document}
\end{filecontents*}



\usepackage{graphicx}

\def\GetImage#1{%
    \immediate\write18{latex dummy}%
    \immediate\write18{dvips dummy}%
    \immediate\write18{ps2pdf dummy.ps}%
    \includegraphics[scale=#1]{dummy}%
}

\begin{document}
\noindent
\fbox{\GetImage{1}}

\end{document}