Plotting functions in two dimensions
Function plots are integral in mathematics for visualizing properties such as roots and extreme points. This recipe explores how to create function plots in a coordinate system easily. Let’s plot the polynomial function f(x) = x3 - 5x.
How to do it...
We’ll use the pgfplots package, built on PGF/TikZ. Now, it’s set to plot a function for us. Here’s the step-by-step process:
- Start with a document class. We decided on the standalone class for this recipe, which is great for creating single graphics with just a small margin. However, you can choose the article class or another one as well:
\documentclass[border=10pt]{standalone}
- Load the pgfplots package:
\usepackage{pgfplots}
- Begin the document and open a tikzpicture environment:
\begin{document} \begin{tikzpicture}
- Begin an axis environment with centered axis lines:
\begin{axis} [axis lines=center]
- Call the...