Manual for Package pgfplots
2D/3D Plots in LATeX, Version 1.18.1
http://sourceforge.net/projects/pgfplots
About PGFPlots: Preliminaries
2.2Upgrade remarks
This release provides a lot of improvements which can be found in all detail in ChangeLog for interested readers. However, some attention is useful with respect to the following changes.
One thing which is common to pgfplots is the key compat: it is strongly suggested to always write it into your .tex files. While this key imposes some work to end-users, it also solves a common requirement: it ensures that your .tex files always result in the same output, even if you install a new version of pgfplots. On the other hand, it allows us as maintainers to solve software defects and introduce changes in behavior, assuming that these changes only affect documents with a decent compatibility level. The precise impact of the compat key, its choices and implications are described in the following sections.
2.2.1New Optional Features¶
pgfplots has been written with backwards compatibility in mind: old TeX files should compile without modifications and without changes in the appearance. However, new features occasionally lead to a different behavior. In such a case, pgfplots will deactivate the new feature.1
Any new features or bugfixes which cause backwards compatibility problems need to be activated manually and explicitly. In order to do so, you should use
in your preamble. This will configure the compatibility layer.
You should have at least compat=1.3. The suggested value is printed to the .log file after running TeX.
Here is a list of changes which are inactive unless one uses a suitable compat level:
-
1. pgfplots 1.18 and 1.17 have no additional constraints and is the same as 1.16 with respect to compatibility levels.
-
2. pgfplots 1.16 has no additional constraints and is the same as 1.15 with respect to compatibility levels.
-
3. pgfplots 1.15 activates 3d log sampling and repairs issues with clip limits for bar plots.
-
4. pgfplots 1.14 changes the way nonuniform colormaps are handled by the system and activates advanced colormap operations (see of colormap).
-
5. pgfplots 1.13 repairs axis labels in polar axis and ensures that the color chosen by shader=flat is independent of z buffer and mesh/ordering. Furthermore, it enables stack negative=separate for all stacked bar plots. Older compatibility levels are present to keep workarounds by end-users.
-
6. pgfplots 1.12 activates lua backend and defines boxplot/estimator=Excel.
-
7. pgfplots 1.11 changes the axis cs: it is now the default coordinate system. If you write \draw (1,2) -- (2,2); pgfplots will automatically treat it as \draw (axis cs:1,2) -- (axis cs:2,2);.
-
8. pgfplots 1.10 has no differences to 1.9 with respect to compatibility.
-
9. pgfplots 1.9 comes with a preset to combine ybar stacked and nodes near coords. Furthermore, it suppresses empty increments in stacked bar plots. In order to activate the new preset, you have to use compat=1.9 or higher.
-
10. pgfplots 1.8 comes with a new revision for alignment of label and tick scale label alignment. Furthermore, it improves the bounding box for hide axis. This revision is enabled with compat=1.8 or higher.
The configuration compat=1.8 is necessary to repair axis lines=center in three-dimensional axes.
-
11. pgfplots 1.7 added new options for bar widths defined in terms of axis units. These are enabled with compat=1.7 or higher.
-
12. pgfplots 1.6 added new options for more accurate scaling and more scaling options for \addplot3 graphics. These are enabled with compat=1.6 or higher.
-
13. pgfplots 1.5.1 interprets circle and ellipse radii as pgfplots coordinates (older versions used pgf unit vectors which have no direct relation to pgfplots). In other words: starting with version 1.5.1, it is possible to write \draw circle[radius=5] inside of an axis. This requires \pgfplotsset{compat=1.5.1} or higher.
Without this compatibility setting, circles and ellipses use low-level canvas units of pgf as in earlier versions.
-
14. pgfplots 1.5 uses log origin=0 as default (which influences logarithmic bar plots or stacked logarithmic plots). Older versions keep log origin=infty. This requires \pgfplotsset{compat=1.5} or higher.
-
15. pgfplots 1.4 has fixed several smaller bugs which might produce differences of about \(1\)–\(2\text {pt}\) compared to earlier releases. This requires \pgfplotsset{compat=1.4} or higher.
-
16. pgfplots 1.3 comes with user interface improvements. The technical distinction between “behavior options” and “style options” of older versions is no longer necessary (although still fully supported).
This is always activated.
-
17. pgfplots 1.3 has a new feature which allows to move axis labels tight to tick labels automatically. This is strongly recommended. It requires \pgfplotsset{compat=1.3} or higher.
Since this affects the spacing, it is not enabled be default.
-
18. pgfplots 1.3 supports reversed axes. It is no longer necessary to use workarounds with negative units.
Take a look at the x dir=reverse key.
Existing workarounds will still function properly. Use \pgfplotsset{compat=1.3} or higher together with x dir=reverse to switch to the new version.
1 In case of broken backwards compatibility, we apologize – and ask you to submit a bug report. We will take care of it.
2.2.2Old Features Which May Need Attention¶
-
1. The scatter/classes feature produces proper legends as of version 1.3. This may change the appearance of existing legends of plots with scatter/classes.
-
2. Starting with pgfplots 1.1, \tikzstyle should no longer be used to set pgfplots options.
Although \tikzstyle is still supported for some older pgfplots options, you should replace any occurrence of \tikzstyle with \pgfplotsset{style name/.style={key-value-list}} or the associated /.append style variant. See Section 4.18 for more detail.
I apologize for any inconvenience caused by these changes.
-
/pgfplots/compat=1.18|1.17|1.16|1.15|1.14|1.13|1.12|1.11|1.10|1.9|1.8|1.7|1.6|1.5.1|1.5|1.4|1.3|pre 1.3|default (initially default) ¶
-
/pgfplots/compat/path replacement=version ¶
-
/pgfplots/compat/labels=version ¶
-
/pgfplots/compat/scaling=version ¶
-
/pgfplots/compat/scale mode=version ¶
-
/pgfplots/compat/empty line=version ¶
-
/pgfplots/compat/plot3graphics=version ¶
-
/pgfplots/compat/bar nodes=version ¶
-
/pgfplots/compat/BB=version ¶
-
/pgfplots/compat/bar width by units=version ¶
-
/pgfplots/compat/pgfpoint substitution=version ¶
-
/pgfplots/compat/general=version ¶
allows to choose between backwards compatibility and most recent features. This key is designed to be the first encountered pgfplots key in a document as it prepares global options.
Occasionally, you might want to use different versions in the same document. Then, provide
in order to restrict the compatibility setting to the actual context (in this case, the figure environment).
See the output of your .log file to get a suggested value for compat.
Use \pgfplotsset{compat=default} to restore the factory settings.
Although typically unnecessary, it is also possible to activate only selected changes and keep compatibility to older versions in general:
Let us assume that we have a document with \pgfplotsset{compat=1.3} and you want to keep it this way.
In addition, you realized that version 1.5.1 supports circles and ellipses. Then, use
All of these keys accept the possible values of the compat key.
The compat/path replacement key controls how radii of circles and ellipses are interpreted.
The compat/labels key controls how axis labels are aligned: either uses adjacent to ticks or with an absolute offset. As of 1.8, it also enables an entirely new revision of the axis label styles. In most cases, you will see no difference – but it repairs axis lines=center in three-dimensional axes.
The compat/scaling key controls some bugfixes introduced in version 1.4 and 1.6: they might introduce slight scaling differences in order to improve the accuracy.
The compat/plot3graphics controls new features for \addplot3 graphics.
The compat/scale mode allows to enable/disable the warning “The content of your 3d axis has CHANGED compared to previous versions” because the axis equal and unit vector ratio features where broken for all versions before 1.6 and have been fixed in 1.6.
The compat/empty line allows to write empty lines into input files in order to generate a jump. This requires compat=1.4 or newer. See empty line for details.
The compat/BB changes to bounding box to be tight even in case of hide axis.
The compat/bar width by units allows to express bar width=1 (i.e. in terms of axis units).
The compat/bar nodes activates presets for ybar stacked and nodes near coords. In addition, it enables stacked ignores zero for stacked bar plots.
The compat/general key controls log origin, lua backend, enable tick line clipping, and boxplot/estimator.
The compat/pgfpoint substitution key determines if axis cs is the default coordinate system (as of 1.11).
The detailed effects can be seen on the beginning of this section.
The value version can be default, a version number, and newest. The value default is the same as pre 1.3 (up to insignificant changes). The use of newest is strongly discouraged: it might cause changes in your document, depending on the current version of pgfplots. Please inspect your .log file to see suggestions for the best possible version.