Example: Plotting a function with a grid

Published 2015-09-24 | Author: Stefan Kottwitz

We will plot a sine function with PGFplots. A default pgfplots axis will be rectangular box that contains the plot. Let’s look at this. In addition, we will add a grid, and we will choose the places for the axis ticks with labels.

The code, and more, is explained in the LaTeX Cookbook, Chapter 10, Advanced Mathematics, Plotting functions in two dimensions.

Download as: [PDF] [TEX]  •  [Open in Overleaf]

Plotting a function with a grid
% Plotting a function with a grid
% Author: Stefan Kottwitz
% https://www.packtpub.com/hardware-and-creative/latex-cookbook
  \begin{axis} [grid, xtick = {-360,-270,...,360}]
    \addplot [domain=-360:360, samples=100, thick] { sin(x) };


Adding comments is currently not enabled.

There are currently 0 comments on this entry.

Scientific and technical areas
LaTeX Cookbook


LaTeX Beginners Guide

Creative Commons License