von tikzgnuplot » Di 8. Sep 2009, 13:33
hi,
ich will gerade mit tikz einen graphen für ne betragsfunktion plotten, doch aus irgendeinem grund macht da gnuplot ziemlichen unsinn:
\begin{tikzpicture}[domain=0:4]
\def\xmin{-2}
\def\xmax{4.2}
\def\ymin{-1}
\def\ymax{4.2}
% Gitter
\draw[very thin,color=gray] (\xmin,\ymin) grid (\xmax,\ymax);
% Achsen
\draw[->] (\xmin,0) -- (\xmax,0) node[right] {\( x \)};
\draw[->] (0,\ymin) -- (0,\ymax) node[above] {\( f(x) \)};
% Funktionen
\draw[color=black, domain=\xmin:\xmax] plot[id=test] function{abs(x+1)}
node[right] {\( f(x) = |x+1| \)};
\end{tikzpicture}
Der Graph berührt dabei nichtmal richtig die X-Achse und hat auf der linken Seite auch noch nen leichten Knick drin.
Bei verschachtelten Betragsfunktionen ist das noch extremer...
Hoffe, jemand kann helfen.. Danke
hi,
ich will gerade mit tikz einen graphen für ne betragsfunktion plotten, doch aus irgendeinem grund macht da gnuplot ziemlichen unsinn:
[code]
\begin{tikzpicture}[domain=0:4]
\def\xmin{-2}
\def\xmax{4.2}
\def\ymin{-1}
\def\ymax{4.2}
% Gitter
\draw[very thin,color=gray] (\xmin,\ymin) grid (\xmax,\ymax);
% Achsen
\draw[->] (\xmin,0) -- (\xmax,0) node[right] {\( x \)};
\draw[->] (0,\ymin) -- (0,\ymax) node[above] {\( f(x) \)};
% Funktionen
\draw[color=black, domain=\xmin:\xmax] plot[id=test] function{abs(x+1)}
node[right] {\( f(x) = |x+1| \)};
\end{tikzpicture}
[/code]
Der Graph berührt dabei nichtmal richtig die X-Achse und hat auf der linken Seite auch noch nen leichten Knick drin.
Bei verschachtelten Betragsfunktionen ist das noch extremer...
Hoffe, jemand kann helfen.. Danke