How to control legend position with PGFPlotsX

If I do

@pgf p = Axis({
                xlabel = "Distance  [m]",
                ylabel = "Temperature [degree Kelvin]",
                title = "",
                legend  = "pos south east"
            },
            …
            );

I get

PGFPlotsX.print_tex(p)
\begin{axis}[xlabel={Distance  [m]}, ylabel={Temperature [degree Kelvin]}, title={}, legend={pos south east}]
    \addplot[color={red}, mark={x}]

but I need legend pos =south east . Has anyone solved thisalready? Would you share?

legend_pos  = "south east"

Splendid! It worked. Should I go see about an update to the documentation? (Or is it perhaps already there?)

I also found that one could insert directly strings into the options array, which are directly passed to latex.
Like this "legend pos={south east}",.

PGFPlotsX has documentation on how to interface with pgfplots, while the documentation of the latter should be used for actual plotting constructs. On a TeXLive installation,

$ texdoc pgfplots

or similar should open the docs.

That said, the manual has an example with legend_pos.

Don’t to that. It works, but PGFPlotsX will treat "legend pos={south east}" as an option with that name (and no value). It is better to do what @fredrikekre suggested.

BTW, I made a PR to the documentation, suggestions welcome:

1 Like

That’s great.

What about the trick with legend_pos getting converted to legend pos? That is non-obvious and except for that example there is no mention in the manual yet.

On the contrary, I think they are explained in the Options section:

Keywords can be entered

  1. as Julia identifiers, which is useful for keywords with no spaces (eg smooth ),

  2. separated by underscores, which are replaced by spaces (eg only_marks will appear in LaTeX code as only marks ),

  3. or quoted as strings, eg "very thick" .

If you think we could make the documentation better, issues/PRs are always welcome.

1 Like

Excellent. I missed it!