Axis & friends

Axis & friends

This section documents constructs which are similar to Axis. In addition to options, they accept all axis elements.

Axis

PGFPlotsX.AxisType.
Axis([options], elements...)

Linear axes, corresponds to axis in PGFPlots.

source

Axis make up the labels and titles etc in the figure and is the standard way of wrapping plots, represented in TeX as

\begin{axis} [...]
    ...
\end{axis}

Examples:

julia> @pgf a = Axis({
              xlabel = "x"
              ylabel = "y"
              title = "Figure"
          },
          PlotInc( Expression("x^2")));

julia> print_tex(a)
\begin{axis}[xlabel={x}, ylabel={y}, title={Figure}]
    \addplot+
        {x^2};
\end{axis}

julia> push!(a, PlotInc(Coordinates([1, 2], [3, 4])));


julia> print_tex(a)
\begin{axis}[xlabel={x}, ylabel={y}, title={Figure}]
    \addplot+
        {x^2};
    \addplot+
        coordinates {
            (1, 3)
            (2, 4)
        }
        ;
\end{axis}

Any struct can be pushed into an Axis. The LaTeX code that is generated is the result of PGFPlotsX.print_tex(io::IO, t::T, ::Axis), where T is the type of the struct. Pushed strings are written out verbatim.

GroupPlot

A GroupPlot is a way of grouping multiple plots in one figure.

GroupPlot([options], contents...)

A group plot, using the groupplots library of PGFPlots.

The contents after the global options are processed as follows:

  1. Options (ie from @pgf {}) will emit a \nextgroupplot with the given options,

  2. nothing is emitted as a \nextgroupplot[group/empty plot],

  3. other values, eg Plot are emitted using print_tex.

source

Example:

julia> @pgf gp = GroupPlot({group_style = { group_size = "2 by 1",},
                                            height = "6cm", width = "6cm"});

julia> for (expr, data) in zip(["x^2", "exp(x)"], ["data1.dat", "data2.dat"])
           push!(gp, Plot(Expression(expr)),  Plot(Table(data)))
       end;

julia> print_tex(gp)
\begin{groupplot}[group style={group size={2 by 1}}, height={6cm}, width={6cm}]
    \addplot
        {x^2};
    \addplot
        table {data1.dat};
    \addplot
        {exp(x)};
    \addplot
        table {data2.dat};
\end{groupplot}

In order to add options to the \nextgroupplot call, simply add arguments in an “option like way” (using @pgf) when you push!

julia> @pgf gp = GroupPlot({group_style = { group_size = "1 by 1",}, height = "6cm", width = "6cm"});

julia> @pgf for (expr, data) in zip(["x^2"], ["data2.dat"])
           push!(gp, {title = "Data $data"}, Plot(Expression(expr)),  Plot(Table(data)))
       end;

julia> print_tex(gp)
\begin{groupplot}[group style={group size={1 by 1}}, height={6cm}, width={6cm}]
    \nextgroupplot[title={Data data2.dat}]
    \addplot
        {x^2};
    \addplot
        table {data2.dat};
\end{groupplot}

PolarAxis

A PolarAxis plots data on a polar grid.

Example:

julia> p = PolarAxis( PlotInc( Coordinates([0, 90, 180, 270], [1, 1, 1, 1])));

julia> print_tex(p)
\begin{polaraxis}
    \addplot+
        coordinates {
            (0, 1)
            (90, 1)
            (180, 1)
            (270, 1)
        }
        ;
\end{polaraxis}

Semilog and log-log axes

SemiLogXAxis([options], elements...)

Log x and linear y axes, corresponds to semilogxaxis in PGFPlots.

source
SemiLogYAxis([options], elements...)

Linear x and log y axes, corresponds to semilogyaxis in PGFPlots.

source
LogLogAxis([options], elements...)

Log-log axes, corresponds to loglogaxis in PGFPlots.

source