Underleaf Logo
Underleaf
BlogPricing
Log InTry Free

Learn PGFPlots

Getting Started

  • What is PGFPlots?
  • PGFPlots for Beginners
  • Basic Setup

PGFPlots for Beginners

A step-by-step guide to creating your first plots with PGFPlots in LaTeX.

The Basic Structure

Every PGFPlots graphic follows this structure:

Your First Plot

Let's plot a simple function:

This creates a basic plot of x² with automatic axis scaling.

Adding Labels and Title

Styling Your Plot

Plotting Data Points

Plot specific coordinates instead of functions:

Line Styles and Markers

Setting Axis Limits

Multiple Plots

Complete Beginner Example

Common Beginner Mistakes

  • Missing compat setting: Always include \pgfplotsset{compat=1.18}
  • Forgetting tikzpicture: The axis environment must be inside tikzpicture.
  • Incorrect function syntax: Use sin(deg(x)) not sin(x) for trig functions.
  • Missing semicolons: Each \addplot command ends with a semicolon.

Next Steps

Continue learning PGFPlots:

  • Basic Setup - Configuration options
  • Line Plots - Detailed line plot tutorial
  • Scatter Plots - Visualize data points

Try it free

Sketch it — AI draws the TikZ.

Upload a photo of a hand-drawn diagram, flowchart, or plot and Underleaf generates the TikZ code for you. 10 free credits every month, no credit card required.

Convert your diagram
A hand-drawn sketch converted into a clean TikZ diagram

PGFPlots for Beginners

A step-by-step guide to creating your first plots with PGFPlots in LaTeX.

The Basic Structure

Every PGFPlots graphic follows this structure:

Your First Plot

Let's plot a simple function:

This creates a basic plot of x² with automatic axis scaling.

Adding Labels and Title

Styling Your Plot

Plotting Data Points

Plot specific coordinates instead of functions:

Line Styles and Markers

Setting Axis Limits

Multiple Plots

Complete Beginner Example

Common Beginner Mistakes

  • Missing compat setting: Always include \pgfplotsset{compat=1.18}
  • Forgetting tikzpicture: The axis environment must be inside tikzpicture.
  • Incorrect function syntax: Use sin(deg(x)) not sin(x) for trig functions.
  • Missing semicolons: Each \addplot command ends with a semicolon.

Next Steps

Continue learning PGFPlots:

Underleaf Logo
Underleaf

Empowering students and researchers with AI-powered tools for academic writing.

Go to appContact us

Company

PricingBlogTutorialsConference TemplatesConference Deadlines

Free Tools

Image to LaTeXExcel to LaTeXArXiv to LaTeXTikZ GeneratorLaTeX Table GeneratorCitation GeneratorThesis GeneratorChrome ExtensionAll Tools

© 2026 Underleaf. All rights reserved.