plotting tangent function

View: New views
2 Messages — Rating Filter:   Alert me  

plotting tangent function

by xlogo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello ,
 
I'm now starting with pgf/tikz and plotting functions.
I've tried to plot the tangent functions using this code:
 
\documentclass[10pt]{article}
\usepackage{pgf,tikz}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[x=2cm,domain=0:4]
\clip (-1,-1.5) rectangle (5.5,4.5);
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[left] {$f(x)$};
\draw[color=blue] plot[samples=500] (\x,{tan(\x r)}) node[right] {$f(x)
= \tan x$};
\end{tikzpicture}
\end{document}
 
I compile with PDFLatex, It seems there is a problem with the tangent
functions.
(I've tried using gnuplot too, it works perfectly but I'd prefer to use
tikz)
 
Thanks in advance for your help



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users

Re: plotting tangent function

by Mark Wibrow-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

Indeed, the tan function is broken. I think this will fix it:

\def\pgfmathtan@#1{%
        \begingroup%
                \edef\pgfmath@tan@temp{#1}%
                \pgfmathsec@{\pgfmath@tan@temp}%
                \let\pgfmath@tan@@temp=\pgfmathresult%
                \pgfmathsin@{\pgfmath@tan@temp}%
                \pgfmath@x=\pgfmathresult pt\relax%
                \pgfmath@x=\pgfmath@tan@@temp\pgfmath@x%
                \pgfmath@returnone\pgfmath@x%
        \endgroup%
}

Regards

Mark

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users
LightInTheBox - Buy quality products at wholesale price