Axis elements
The following types are accepted as elements of Axis
& friends:
legend specifications:
Legend
,LegendEntry
,strings, which are inserted verbatim.
This section documents these.
Plots
A plot is an element inside an axis. It can be a wide range of constructs, from a simple line to a 3D surface. A plot is created by wrapping one of the data structures.
PGFPlots uses \addplot
& friends for visualization that uses a single data source, in most cases drawn using the same style. If you want to plot multiple sources of data that share axes, eg two time series, your axis will have multiple “plots” in the terminology of PGFPlots.
Plot and PlotInc
For \addplot
and \addplot+
, respectively.
PGFPlotsX.Plot
— Typestruct Plot <: PGFPlotsX.OptionType
Corresponds to the \addplot[3][+]
family of pgfplot
commands.
Instead of the default constructor, use Plot([options], data, trailing...)
and similar (PlotInc
, Plot3
, Plot3Inc
) in user code.
PGFPlotsX.PlotInc
— FunctionPlotInc([options::Options], data, trailing...)
Corresponds to the \addplot+
form in PGFPlots.
For the interpretation of the other arguments, see Plot(::Options, ::PlotData, ...)
.
Example:
julia> p = @pgf PlotInc({ blue }, Table("plotdata/invcum.dat"));
julia> print_tex(p)
\addplot+[blue]
table {plotdata/invcum.dat};
Plot3
Plot3
will use the \addplot3
command instead of \addplot
to draw 3D graphics. Otherwise it works the same as Plot
. The incremental variant is Plot3Inc
.
PGFPlotsX.Plot3
— FunctionPlot3([options::Options], data, trailing...)
Corresponds to the \addplot3
form in PGFPlots.
For the interpretation of the other arguments, see Plot(::Options, ::PlotData, ...)
.
PGFPlotsX.Plot3Inc
— FunctionPlot3Inc([options::Options], data, trailing...)
Corresponds to the \addplot3+
form in PGFPlots.
For the interpretation of the other arguments, see Plot(::Options, ::PlotData, ...)
.
Example:
julia> x, y, z = [1, 2, 3], [2, 4, 8], [3, 9, 27];
julia> p = @pgf Plot3({ very_thick }, Coordinates(x, y, z));
julia> print_tex(p)
\addplot3[very thick]
coordinates {
(1,2,3)
(2,4,9)
(3,8,27)
}
;
Legends
PGFPlotsX.Legend
— TypeLegend(labels)
Corresponds to \legend{ ... }
in PGFPlots. Specifies multiple legends for an axis, its position is irrelevant.
labels
are wrapped in {}
s, so they can contain ,
.
PGFPlotsX.LegendEntry
— TypeLegendEntry([options::Options], name, [isexpanded])
Corresponds to the \addlegendentry
and \addlegendentryexpanded
forms of PGFPlots.
A Legend
can be used to add legends to an axis, for multiple plots at the same time. In contrast, LegendEntry
applies to the preceding plot.
Example:
julia> print_tex(Legend(["Plot A", "Plot B"]))
\legend{{Plot A},{Plot B}}
Horizontal and vertical lines
HLine
and VLine
have no equivalent constructs in pgfplots
, they are provided for convenient drawing of horizontal and vertical lines. When options are used, they are passed to the TikZ function \draw[...]
.
PGFPlotsX.HLine
— TypeHLine([options], y)
A horizontal line at y
.
PGFPlotsX.VLine
— TypeVLine([options], x)
A vertical line at x
.
Horizontal and vertical bands
HBand
and VBand
have no equivalent constructs in pgfplots
, they are provided for convenient drawing of horizontal and vertical bands. These bands are simply rectangles that span across an axis. When options are used, they are passed to the TikZ function \draw[...]
.
PGFPlotsX.HBand
— TypeHBand([options], ymin, ymax)
A horizontal band from ymin
to ymax
.
PGFPlotsX.VBand
— TypeVBand([options], xmin, xmax)
A vertical band from xmin
to xmax
.
Using LaTeX code directly
In case there is no type defined in this package for some construct, you can use a String
in an axis, and it is inserted verbatim into the generated LaTeX code. Raw string literals and the package LaTeXStrings are useful to avoid a lot of escaping.
The gallery has some detailed examples, eg for annotating plots.