Überarbeitungsverlauf[Zurück]
Klicke auf Einblenden/Ausblenden von Überarbeitungen 2

12 Mär '14, 19:07

Henri's gravatar image

Henri
15.7k133943

# Bemerkungen Man muss beachten, dass 5/x eine Singularität bei 0 hat. An diesem Punkt ist der Funktionswert unendlich, was für PGF etwas schwierig darzustellen ist, weshalb man mit Fehlern konfrontiert wird wie: - ``! Package PGF Math Error: You've asked me to divide `5' by `0', but I cannot divide any number by `0' (in '{5/0}').`` - `? Dimensions too large` # Methode 1: Ti<i>k</i>Z Der Vorteil in der Benutzung von TikZ liegt hier darin, dass man leicht Nodes auf dem Plot platzieren kann. Der Nachteil ist, dass man die x- und y-Achse skalieren muss, weil die Zeichnung sonst 220cm breit sein müsste. ## Implementierung \documentclass[tikz,border=3mm]{standalone} \begin{document} \begin{tikzpicture}[xscale=0.04,yscale=0.08,domain=0.125:220,samples=400] \draw[->] (-10,0) -- (225,0) node[below] {$x$}; \draw[->] (0,-5) -- (0,45) node[left] {$y$}; \foreach \i in {50,100,...,200} { \draw (\i,1) -- (\i,-1) node[below] {$\i$}; } \foreach \i in {10,20,...,40} { \draw (1,\i) -- (-1,\i) node[left] {$\i$}; } \draw[blue] plot (\x,{40-0.2*\x}); \draw[red] plot (\x,{5/\x}); \end{tikzpicture} \end{document} ## Ausgabe > ![tikz][1] # Methode 2: PGFPlots Diese Methode ist viel eleganter und der Quelltext ist viel kürzer. ## Implementierung \documentclass[tikz,border=3mm]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[domain=0.125:220,samples=400] \addplot+[mark=none] {40-0.2*x}; \addplot+[mark=none] {5/x}; \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[ domain=0.125:220, xmin=-10, xmax=220, ymin=-5, ymax=45, samples=400, axis y line=center, axis x line=middle, ] \addplot+[mark=none] {40-0.2*x}; \addplot+[mark=none] {5/x}; \end{axis} \end{tikzpicture} \end{document} ## Ausgabe > ![pgfplots1][2] ![pgfplots2][3] # Methode 3: PSTricks (Nur zum Spaß) Mit dem Paket `pst-plot` erhält man viele Makros zum Plotten von Funktionen. Außerdem ist PSTricks viel schneller beim Plotten von Funkionen als Ti<i>k</i>Z, weil es auf der Postscript-Sprache basiert. ## Implementierung Compile with `xelatex` or `latex -> dvips -> ps2pdf`. \documentclass[pstricks,border=3mm]{standalone} \usepackage{pst-plot} \begin{document} \begin{pspicture}[xAxisLabel=$x$,yAxisLabel=$y$](-0.5,0)(0.5,6.5) \begin{psgraph}[arrows=->,Dx=50,Dy=10](0,0)(-10,-5)(220,45){8cm}{6cm} \psplot[plotpoints=200,linecolor=blue]{0}{220}{40 0.2 x mul sub} \psplot[plotpoints=200,linecolor=red]{0.125}{220}{5 x div} \end{psgraph} \end{pspicture} \begin{pspicture}[xAxisLabel=$x$,yAxisLabel=$y$,xAxisLabelPos={c,-12},yAxisLabelPos={-35,c}](-1,-1)(0.5,6.5) \begin{psgraph}[axesstyle=frame,xticksize=-5 45,yticksize=-10 220,Dx=50,Dy=10](0,0)(-10,-5)(220,45){8cm}{6cm} \psplot[plotpoints=200,linecolor=blue]{0}{220}{40 0.2 x mul sub} \psplot[plotpoints=200,linecolor=red]{0.125}{220}{5 x div} \end{psgraph} \end{pspicture} \end{document} ## Ausgabe > ![ps1][4] ![ps2][5] [1]: http://texwelt.de/wissen/upfiles/1.png http://texwelt.de/wissen/upfiles/1_1.png [2]: http://texwelt.de/wissen/upfiles/2.png http://texwelt.de/wissen/upfiles/2_1.png [3]: http://texwelt.de/wissen/upfiles/3.png http://texwelt.de/wissen/upfiles/3_1.png [4]: http://texwelt.de/wissen/upfiles/4.png http://texwelt.de/wissen/upfiles/4_1.png [5]: http://texwelt.de/wissen/upfiles/5.pnghttp://texwelt.de/wissen/upfiles/5_1.png
Klicke auf Einblenden/Ausblenden von Überarbeitungen 1

12 Mär '14, 18:59

Henri's gravatar image

Henri
15.7k133943

# Bemerkungen Man muss beachten, dass 5/x eine Singularität bei 0 hat. An diesem Punkt ist der Funktionswert unendlich, was für PGF etwas schwierig darzustellen ist, weshalb man mit Fehlern konfrontiert wird wie: - ``! Package PGF Math Error: You've asked me to divide `5' by `0', but I cannot divide any number by `0' (in '{5/0}').`` - `? Dimensions too large` # Methode 1: Ti<i>k</i>Z Der Vorteil in der Benutzung von TikZ liegt hier darin, dass man leicht Nodes auf dem Plot platzieren kann. Der Nachteil ist, dass man die x- und y-Achse skalieren muss, weil die Zeichnung sonst 220cm breit sein müsste. ## Implementierung \documentclass[tikz,border=3mm]{standalone} \begin{document} \begin{tikzpicture}[xscale=0.04,yscale=0.08,domain=0.125:220,samples=400] \draw[->] (-10,0) -- (225,0) node[below] {$x$}; \draw[->] (0,-5) -- (0,45) node[left] {$y$}; \foreach \i in {50,100,...,200} { \draw (\i,1) -- (\i,-1) node[below] {$\i$}; } \foreach \i in {10,20,...,40} { \draw (1,\i) -- (-1,\i) node[left] {$\i$}; } \draw[blue] plot (\x,{40-0.2*\x}); \draw[red] plot (\x,{5/\x}); \end{tikzpicture} \end{document} ## Ausgabe > ![tikz][1] # Methode 2: PGFPlots Diese Methode ist viel eleganter und der Quelltext ist viel kürzer. ## Implementierung \documentclass[tikz,border=3mm]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[domain=0.125:220,samples=400] \addplot+[mark=none] {40-0.2*x}; \addplot+[mark=none] {5/x}; \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[ domain=0.125:220, xmin=-10, xmax=220, ymin=-5, ymax=45, samples=400, axis y line=center, axis x line=middle, ] \addplot+[mark=none] {40-0.2*x}; \addplot+[mark=none] {5/x}; \end{axis} \end{tikzpicture} \end{document} ## Ausgabe > ![pgfplots1][2] ![pgfplots2][3] # Methode 3: PSTricks (Nur zum Spaß) Mit dem Paket `pst-plot` erhält man viele Makros zum Plotten von Funktionen. Außerdem ist PSTricks viel schneller beim Plotten von Funkionen als Ti<i>k</i>Z, weil es auf der Postscript-Sprache basiert. ## Implementierung Compile with `xelatex` or `latex -> dvips -> ps2pdf`. \documentclass[pstricks,border=3mm]{standalone} \usepackage{pst-plot} \begin{document} \begin{pspicture}[xAxisLabel=$x$,yAxisLabel=$y$](-0.5,0)(0.5,6.5) \begin{psgraph}[arrows=->,Dx=50,Dy=10](0,0)(-10,-5)(220,45){8cm}{6cm} \psplot[plotpoints=200,linecolor=blue]{0}{220}{40 0.2 x mul sub} \psplot[plotpoints=200,linecolor=red]{0.125}{220}{5 x div} \end{psgraph} \end{pspicture} \begin{pspicture}[xAxisLabel=$x$,yAxisLabel=$y$,xAxisLabelPos={c,-12},yAxisLabelPos={-35,c}](-1,-1)(0.5,6.5) \begin{psgraph}[axesstyle=frame,xticksize=-5 45,yticksize=-10 220,Dx=50,Dy=10](0,0)(-10,-5)(220,45){8cm}{6cm} \psplot[plotpoints=200,linecolor=blue]{0}{220}{40 0.2 x mul sub} \psplot[plotpoints=200,linecolor=red]{0.125}{220}{5 x div} \end{psgraph} \end{pspicture} \end{document} ## Ausgabe > ![ps1][4] ![ps2][5] [1]: http://texwelt.de/wissen/upfiles/1.png [2]: http://texwelt.de/wissen/upfiles/2.png [3]: http://texwelt.de/wissen/upfiles/3.png [4]: http://texwelt.de/wissen/upfiles/4.png [5]: http://texwelt.de/wissen/upfiles/5.png

Willkommen, erstes Mal hier? Schau mal unter FAQ!

×