Underleaf Logo
Underleaf
PricingAboutBlog
Log InGet started

Learn PGFPlots

Getting Started

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

Axis Customization in PGFPlots

Customize every aspect of your plot axes for publication-quality graphics.

Axis Labels

\begin{axis}[ xlabel={Time ($t$) [s]}, ylabel={Velocity ($v$) [m/s]}, zlabel={Height ($h$) [m]}, % For 3D plots % Styled labels xlabel style={ font=\large\bfseries, color=blue }, ylabel style={ font=\large\bfseries, color=red } ]

Axis Limits

\begin{axis}[ xmin=-10, xmax=10, ymin=0, ymax=100, % Enlarge limits slightly enlarge x limits=0.1, % 10% padding enlarge y limits={abs=5}, % 5 units padding % Auto-scale options enlargelimits=true, % Auto-enlarge all % Or restrict to data xmin={}, xmax={}, % Auto from data ]

Tick Marks

\begin{axis}[ % Custom tick positions xtick={0, 1, 2, 3, 4, 5}, ytick={0, 25, 50, 75, 100}, % Auto ticks with step xtick distance=0.5, ytick distance=10, % Minor ticks minor xtick={0.5, 1.5, 2.5, 3.5, 4.5}, minor ytick num=4, % 4 minor ticks between major % Tick direction tick align=inside, % or: outside, center major tick length=4pt, minor tick length=2pt ]

Tick Labels

\begin{axis}[ % Custom labels xtick={1, 2, 3, 4}, xticklabels={Jan, Feb, Mar, Apr}, % Label formatting xticklabel style={ font=\small, rotate=45, anchor=east }, % Number formatting yticklabel={\pgfmathprintnumber{\tick}\%}, /pgf/number format/.cd, fixed, precision=2, % Scientific notation ytick scale label code/.code={$\times 10^{#1}$} ]

Logarithmic Axes

% Semi-log (y-axis logarithmic) \begin{semilogyaxis}[ xlabel={$x$}, ylabel={$y$} ] \addplot {exp(x)}; \end{semilogyaxis} % Semi-log (x-axis logarithmic) \begin{semilogxaxis} \addplot {log10(x)}; \end{semilogxaxis} % Log-log (both axes logarithmic) \begin{loglogaxis} \addplot {x^2}; \end{loglogaxis} % Or use options in regular axis \begin{axis}[ xmode=log, ymode=log, log basis x=10, log basis y=e ]

Grid Lines

\begin{axis}[ % Grid options grid=major, % or: minor, both, none grid style={ line width=0.5pt, draw=gray!50 }, % Major grid style major grid style={ line width=0.8pt, draw=gray!70 }, % Minor grid style minor grid style={ line width=0.3pt, draw=gray!30, dashed }, % Only specific axis grid xmajorgrids=true, ymajorgrids=false, xminorgrids=true ]

Axis Lines

\begin{axis}[ % Axis line positions axis lines=left, % or: middle, center, right, box % Axis through origin axis lines=middle, axis x line=middle, axis y line=middle, % Axis line style axis line style={ thick, ->, >=stealth }, % Hide specific axis hide x axis, hide y axis ]

Multiple Y-Axes

\begin{tikzpicture} \begin{axis}[ axis y line*=left, xlabel={Time}, ylabel={Temperature ($^\circ$C)}, ymin=0, ymax=100 ] \addplot[blue, thick] coordinates {(0,20) (1,40) (2,60) (3,80)}; \label{plot_temp} \end{axis} \begin{axis}[ axis y line*=right, axis x line=none, ylabel={Pressure (bar)}, ymin=0, ymax=10 ] \addplot[red, thick, dashed] coordinates {(0,1) (1,3) (2,5) (3,8)}; \label{plot_pressure} \end{axis} \end{tikzpicture}

Axis Breaks

% Discontinuous axis (manual approach) \begin{axis}[ ymin=0, ymax=50, ytick={0, 10, 20, 45, 50}, yticklabels={0, 10, 20, 90, 100}, % Add break indicator manually extra y ticks={25}, extra y tick labels={}, extra y tick style={ major tick length=0pt, yticklabel style={ /pgfplots/discontinuity } } ]

Date Axes

\usepgfplotslibrary{dateplot} \begin{axis}[ date coordinates in=x, xticklabel={\day/\month}, xticklabel style={rotate=45, anchor=east} ] \addplot coordinates { (2023-01-01, 10) (2023-02-01, 25) (2023-03-01, 18) (2023-04-01, 32) }; \end{axis}

Next Steps

Continue learning PGFPlots:

  • Legends - Customize plot legends
  • Colors and Styles - Visual customization
  • Multiple Plots - Subplots and grouping

Axis Customization in PGFPlots

Customize every aspect of your plot axes for publication-quality graphics.

Axis Labels

\begin{axis}[ xlabel={Time ($t$) [s]}, ylabel={Velocity ($v$) [m/s]}, zlabel={Height ($h$) [m]}, % For 3D plots % Styled labels xlabel style={ font=\large\bfseries, color=blue }, ylabel style={ font=\large\bfseries, color=red } ]

Axis Limits

\begin{axis}[ xmin=-10, xmax=10, ymin=0, ymax=100, % Enlarge limits slightly enlarge x limits=0.1, % 10% padding enlarge y limits={abs=5}, % 5 units padding % Auto-scale options enlargelimits=true, % Auto-enlarge all % Or restrict to data xmin={}, xmax={}, % Auto from data ]

Tick Marks

\begin{axis}[ % Custom tick positions xtick={0, 1, 2, 3, 4, 5}, ytick={0, 25, 50, 75, 100}, % Auto ticks with step xtick distance=0.5, ytick distance=10, % Minor ticks minor xtick={0.5, 1.5, 2.5, 3.5, 4.5}, minor ytick num=4, % 4 minor ticks between major % Tick direction tick align=inside, % or: outside, center major tick length=4pt, minor tick length=2pt ]

Tick Labels

\begin{axis}[ % Custom labels xtick={1, 2, 3, 4}, xticklabels={Jan, Feb, Mar, Apr}, % Label formatting xticklabel style={ font=\small, rotate=45, anchor=east }, % Number formatting yticklabel={\pgfmathprintnumber{\tick}\%}, /pgf/number format/.cd, fixed, precision=2, % Scientific notation ytick scale label code/.code={$\times 10^{#1}$} ]

Logarithmic Axes

% Semi-log (y-axis logarithmic) \begin{semilogyaxis}[ xlabel={$x$}, ylabel={$y$} ] \addplot {exp(x)}; \end{semilogyaxis} % Semi-log (x-axis logarithmic) \begin{semilogxaxis} \addplot {log10(x)}; \end{semilogxaxis} % Log-log (both axes logarithmic) \begin{loglogaxis} \addplot {x^2}; \end{loglogaxis} % Or use options in regular axis \begin{axis}[ xmode=log, ymode=log, log basis x=10, log basis y=e ]

Grid Lines

\begin{axis}[ % Grid options grid=major, % or: minor, both, none grid style={ line width=0.5pt, draw=gray!50 }, % Major grid style major grid style={ line width=0.8pt, draw=gray!70 }, % Minor grid style minor grid style={ line width=0.3pt, draw=gray!30, dashed }, % Only specific axis grid xmajorgrids=true, ymajorgrids=false, xminorgrids=true ]

Axis Lines

\begin{axis}[ % Axis line positions axis lines=left, % or: middle, center, right, box % Axis through origin axis lines=middle, axis x line=middle, axis y line=middle, % Axis line style axis line style={ thick, ->, >=stealth }, % Hide specific axis hide x axis, hide y axis ]

Multiple Y-Axes

\begin{tikzpicture} \begin{axis}[ axis y line*=left, xlabel={Time}, ylabel={Temperature ($^\circ$C)}, ymin=0, ymax=100 ] \addplot[blue, thick] coordinates {(0,20) (1,40) (2,60) (3,80)}; \label{plot_temp} \end{axis} \begin{axis}[ axis y line*=right, axis x line=none, ylabel={Pressure (bar)}, ymin=0, ymax=10 ] \addplot[red, thick, dashed] coordinates {(0,1) (1,3) (2,5) (3,8)}; \label{plot_pressure} \end{axis} \end{tikzpicture}

Axis Breaks

% Discontinuous axis (manual approach) \begin{axis}[ ymin=0, ymax=50, ytick={0, 10, 20, 45, 50}, yticklabels={0, 10, 20, 90, 100}, % Add break indicator manually extra y ticks={25}, extra y tick labels={}, extra y tick style={ major tick length=0pt, yticklabel style={ /pgfplots/discontinuity } } ]

Date Axes

\usepgfplotslibrary{dateplot} \begin{axis}[ date coordinates in=x, xticklabel={\day/\month}, xticklabel style={rotate=45, anchor=east} ] \addplot coordinates { (2023-01-01, 10) (2023-02-01, 25) (2023-03-01, 18) (2023-04-01, 32) }; \end{axis}

Next Steps

Continue learning PGFPlots:

Underleaf Logo
Underleaf

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

Go to appContact us

Company

PricingBlogTutorialsAffiliate Program

Free Tools

Image to LaTeXExcel to LaTeXArXiv to LaTeXTikZ GeneratorThesis GeneratorChrome ExtensionAll Tools

© 2026 Underleaf. All rights reserved.