pgf-tikz / pgfplots

pgfplots - A TeX package to draw normal and/or logarithmic plots directly in TeX in two and three dimensions with a user-friendly interface and pgfplotstable - a TeX package to round and format numerical tables. Examples in manuals and/or on web site.
http://pgfplots.sourceforge.net/
198 stars 34 forks source link

[legend pos] Introduce `legend pos=outer south` #274

Open pgf-tikz-bot opened 11 years ago

pgf-tikz-bot commented 11 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/feature-requests/40/ Author: tentotwo Timestamp: 2013-05-22 16:55:40

At the moment, there's only one option for placing the legend outside the axis area: legend pos=outer north east. It would be useful to have at least the option outer south available as well, which would place the legend at the bottom of the plot. As explained on the mailling list http://pgfplots-features.706524.n3.nabble.com/Pgfplots-features-legend-pos-outer-td826774.html, this would require checking whether there's an axis label or not, since that would influence the placement.

One way to implement this would be using the following code snippet. It assigns an alias to the x axis label, which then makes it possible to check whether the axis label has been created. If it has, the legend is placed relative to the axis label, if it hasn't, the xticklabel cs is used. See http://tex.stackexchange.com/questions/115490/pgfplots-scale-legend-position-when-below-xlabel for an example

\makeatletter
\pgfplotsset{
    every axis x label/.append style={
        alias=current axis xlabel,
    },
    legend pos/outer south/.style={
        /pgfplots/legend style={
            at={%
                (%
                    \@ifundefined{pgf@sh@ns@current axis xlabel}%
                    {xticklabel cs:0.5}%
                    {current axis xlabel.south}%
                )%
            },
            anchor=north
        },
    },
}
\makeatother
pgf-tikz-bot commented 7 years ago

Migrated from SourceForge https://sourceforge.net/p/pgfplots/feature-requests/40/#6f3f Author: mo-gul Timestamp: 2017-02-04 10:15:56.350000

For the record: I want this feature request + a few more positions which can be found in https://sourceforge.net/p/pgfplots/feature-requests/58/