What Does \addplot+ Do in PGFPlots?
At a glance
- 1. Start with cycling
PGFPlots normally chooses a style from the active cycle list for each plot.
- 2. Use the plus
Write \addplot+[options] to retain that cycle-list style and add plot-specific options.
- 3. Check overlaps
Options you add can change the same settings supplied by the cycle list.
The + in \addplot+ is a PGFPlots syntax marker, not an addition operator. It controls the order in which the command applies the active plot cycle list—the list of styles PGFPlots cycles through as it draws plots—and the options you supply.
Use \addplot+ when you want the current cycle-list style and also want to supply extra options for that particular plot. The cycle-list style is applied first, then the options you give, so your options override cycle-list settings with the same key. By contrast, \addplot[<options>] normally still uses the cycle-list entry, but applies it after the options you provide. Cycle-list settings therefore take precedence when they conflict.
The practical difference
Suppose the cycle list assigns each plot a color and a marker. With \addplot+[mark=none], the plot keeps its cycle-list color but has no marker. The local mark=none setting is applied after the cycle-list style, so it overrides the marker while leaving the color intact.
With \addplot[mark=none], the cycle-list entry is applied after the explicit plot options. If that entry specifies a marker, its marker setting takes precedence over mark=none; the cycle-list color is also applied. Settings in the cycle-list entry do not override options for keys they do not specify.
| Command | Effect when you provide options |
|---|---|
\addplot[<options>] | Applies the supplied options, then the current cycle-list style; cycle-list settings win on conflicts. |
\addplot+[<options>] | Applies the current cycle-list style, then the supplied options; supplied settings win on conflicts. |
For example, mark=none overrides a marker specified by the cycle list with \addplot+, while leaving unrelated cycle-list settings, such as color, intact. With ordinary \addplot, the cycle-list marker takes precedence instead.
Worked example
This complete example uses a built-in color cycle. The first two plots keep their cycle-list colors and suppress markers. The third plot supplies red, but because it uses ordinary \addplot, the cycle-list color is applied afterward and takes precedence.
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
cycle list name=color list,
domain=-1:1,
samples=50,
legend entries={$x$, $x^2$, $x^3$}
]
\addplot+[mark=none, thick] {x};
\addplot+[mark=none, thick] {x^2};
\addplot[red, mark=none, thick] {x^3};
\end{axis}
\end{tikzpicture}
\end{document}
The first command takes the first cycle-list color and then applies mark=none and thick. The second takes the next cycle-list color and applies those same settings. The third also uses a cycle-list entry, which is applied after its supplied options; in particular, the cycle-list color takes precedence over red. To make that plot red, use \addplot+[red, mark=none, thick] instead. The axis-level settings, such as domain and samples, apply to all three plots.
What the plus does not do
The plus does not request a different plot type, add another data series, or change the function being evaluated. It changes the order in which the plot options and cycle-list style are applied. The plot still uses the ordinary \addplot syntax for coordinates, tables, or functions.
Both commands are useful. Use \addplot when you want the cycle-list style to take precedence over conflicting per-plot options. Use \addplot+ when you want to preserve the cycle-list style while allowing your per-plot options to override it. If you want a cycle-list color but a custom marker, for instance, the plus form is usually the convenient choice.
Common mistakes
- Expecting
\addplot[mark=none]to override a cycle-list marker. Use\addplot+[mark=none]if you want the local setting to take precedence while retaining other cycle-list settings, such as color. - Thinking the plus means “add another plot.” It changes option handling; the command still draws one plot.
- Assuming every cycle-list setting must survive. With
\addplot+, a local option can override a cycle-list setting with the same key; with ordinary\addplot, the cycle-list setting takes precedence on conflicts. - Confusing axis options with plot options. Settings in
\begin{axis}[...]configure the axis; the options immediately after\addplotor\addplot+configure that plot.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.