-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

LaTeX Cookbook
By :

Functions play an important role in mathematics. To visualize them to better understand their properties, so that we can see roots and extreme points, we can plot them in a coordinate system. In this recipe, we will see how to easily plot functions. First, let's print the polynomial function f(x) = x^3 - 5*x.
We will use the pgfplots
package, which is based on PGF/TikZ. We already used it in the previous chapter to draw various diagrams. Now it will plot a function for us. Follow these steps:
Start with a document class. For this recipe, we decide on the standalone
class, which is great for creating single graphics with just a small margin, but you can choose the article
class or another one as well.
\documentclass[border=10pt]{standalone}
Load the pgfplots
package:
\usepackage{pgfplots}
Start the document and open a tikzpicture
environment:
\begin{document} \begin{tikzpicture}
Begin an axis
environment with centered axis lines:
\begin{axis...