Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Producing a single legend for all subplots of a multiplot

5,937 views
Skip to first unread message

Uncle Noah

unread,
Apr 23, 2009, 7:32:14 AM4/23/09
to
Hi there

is there any convenient way to produce a single legend for the
subplots in a multiplot. Preferrably outside the
subplot areas.

This is what i have in mind (for a 2x2 multiplot layout):


----------- -----------
| subplot 1 | | subplot 2 |
----------- -----------

----------- --------
| subplot 3 | | LEGEND |
----------- --------


The legend is the same for all subplots.

Thanks in advance.

Nikolaos Kavvadias

sfeam

unread,
Apr 23, 2009, 1:23:07 PM4/23/09
to
Uncle Noah wrote:

> Hi there
>
> is there any convenient way to produce a single legend for the
> subplots in a multiplot. Preferrably outside the
> subplot areas.

The multiplot command itself has a "title" option that will put
a caption at the top of the page. But it would be hard to use to
produce the layout you show below.

Uncle Noah

unread,
Apr 24, 2009, 6:42:48 AM4/24/09
to
On 23 Απρ, 20:23, sfeam <sf...@users.sourceforge.net> wrote:
> Uncle Noah wrote:
> > Hi there
>
> > is there any convenient way to produce a single legend for the
> > subplots in a multiplot. Preferrably outside the
> > subplot areas.
>
> The multiplot command itself has a "title" option that will put
> a caption at the top of the page.  But it would be hard to use to
> produce the layout you show below.

Hi

with a little trial and error i have achieved what i wanted

...
set key default
set key box
set multiplot layout 2,2
set key off
...
set title "Title1"
plot ...
set title "Title2"
plot ...
set key at num,num # an absolute numerical position according to the
coord system used
show key
set title "Title3"
plot ...
unset multiplot

Just in case anybody else needs it.

Nikolaos Kavvadias

Darby

unread,
Apr 26, 2009, 9:06:08 AM4/26/09
to
I don't think you have to go through quite so much trouble in your
case. Since the legend is the same for all plots all you have to do
is turn the key on and force it to the same position every time:

...
set key default
set key box
set multiplot layout 2,2

set key screen 0.75, 0.25


...
set title "Title1"
plot ...
set title "Title2"
plot ...

set title "Title3"
plot ...
unset multiplot


This will draw the key 3 times but if it's exactly the same (i.e. the
`title ""` is the same in all your plots), they will overlap exactly
and you can't tell. Depending on the version of gnuplot you are use,
you might need to change the key command to:

set key at screen 0.75, 0.25

On Apr 24, 5:42 am, Uncle Noah <nk...@skiathos.physics.auth.gr> wrote:

0 new messages