Re: [Pgfplots-features] Controlling the order of legend entries
Brought to you by:
cfeuersaenger,
ludewich
|
From: Christian F. <cfe...@go...> - 2011-01-20 20:12:47
|
Hello Robert,
legends can be fully customized, but only by means of the \label and
\ref approach. In other words: you need to build an own tikz matrix
(perhaps using the same styles) and you need to fill it manually.
An example would be
\begin{tikzpicture}
\begin{axis}[
extra description/.code={
\matrix[/pgfplots/every axis legend]
{
\ref{2x} \pgfmatrixnextcell \node{$2\cdot x$};\\
\ref{x} \pgfmatrixnextcell \node{$x$};\\
};
}
]
\addplot {x};
\label{x}
\addplot {2*x};
\label{2x}
\end{axis}
\end{tikzpicture}
I admit that it doesn't look perfect - seems something with the vertical
alignment is not as in the original legend implementation.
Perhaps you find out how to fix the vertical alignment here; I guess the
tikz manual will be the resource of choice.
The \ref{} command, when found inside of a tikzpicture, will make a
scope and issue a '\draw....' command corresponding to the graphics.
Perhaps a variant of \node{\ref{...}}; does the job (did not work when I
tried it, though).
In short: you may need to customize your legend (semi) manually, which
is possible.
Best regards
Christian
Am 13.01.2011 09:51, schrieb Robert Read:
> Hello everyone,
>
> As I understand it, the order of the legend entries should generally
> match the order of the plots. I understand that I can reverse this
> order by using the reverse legend=true or legend reversed=true
> commands, but is it possible to control the order of the legend
> entries independently of the order of the plots? Let's say for
> example that the order of my plots is 1, 2, 3, 4, but I want to list
> the corresponding legend entries in the order 3, 1, 4, 2. Is this
> possible?
>
> Any assistance would be very gratefully received.
>
> Best regards,
>
> Robert
>
>
> Robert Read
> Department of Mechanical Engineering
> Technical University of Denmark
> Nils Koppels Allé
> Building 403 Room 009
> DK-2800 Kgs. Lyngby
> Denmark
>
> tel: 0045 4525 1376
> e-mail: rob...@ca...
>
>
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> Pgfplots-features mailing list
> Pgf...@li...
> https://lists.sourceforge.net/lists/listinfo/pgfplots-features
>
|