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

Howto arrange 2 rows inside the legend box?

4,171 views
Skip to first unread message
Message has been deleted

pem

unread,
May 1, 2010, 5:52:28 AM5/1/10
to
Hello all,

I am trying to plot 9 curves in a single plot. Now I have some
difficulties about the legends and need your help. I'd like to have
them arranged into 2 rows. I looked up the manual and wrote the 'key'
option like this:

set key box linestyle 1 right top Left reverse samplen 1 spacing 1
height 4 width 0

but it doesn't work well. The box I get in the final output have 2
rows, but the spacing in the box controlled by 'height' cannot be
eliminated. when decrease this parameter, the legends in the box fall
back into only 1 row. What should I do to raise the legend box to
avoid overlapping
with the curves?

I placed the resulted picture here: http://pem.freeshell.org/pem-gunplot.jpg

Thank you in advance for any comments and suggestions.

Bests,

pem

Vadim Biktashev

unread,
May 1, 2010, 6:42:50 AM5/1/10
to
Hello pem,
I am not very proficient with gnuplot myself but I think the answer to your question may depend
on many other things, e.g. exactly which terminal you are using with what parameters and possibly
other things.
Do you think you could give us the whole script you are using?
- Vadim

Vadim Biktashev

unread,
May 1, 2010, 6:43:11 AM5/1/10
to
Hello pem,
I am not very proficient with gnuplot myself but I think the answer to your question may depend
on many other things, e.g. exactly which terminal you are using with what parameters and possibly
other things.
Do you think you could give us the whole script you are using?
- Vadim

pem

unread,
May 1, 2010, 6:55:49 AM5/1/10
to
On 5月1日, 下午6时43分, Vadim Biktashev <biktas...@ntlworld.com> wrote:
> Hello pem,
> I am not very proficient with gnuplot myself but I think the answer to your question may depend
> on many other things, e.g. exactly which terminal you are using with what parameters and possibly
> other things.
> Do you think you could give us the whole script you are using?
> - Vadim

Hello Vadim, thank you for your reply.

I am running gnuplot 4.4 patchlevel 0, on a Linux amd64 desktop, the
result is set to an eps file.
The script I am using is as follow:

##########################################################
set term postscript eps enhanced color
set grid
set style data linespoints
set output "pem-gnuplot.eps"


set key box linestyle 1 right top Left reverse samplen 1 spacing 1
height 4 width 0

set size 1,0.5
set xra [-3:3]
set xtics -4,1,4
set mxtics 5
set xlabel "Energy (eV)"

set yra [0:90 ]
set ylabel "Transmisson"
set ytics 0,10,90
set mytics 2

plot "data_15.txt" title "15%" linetype 1 linewidth 0.2 pointtype 1
pointsize 0.2 linecolor 1, \
"data_10.txt" title "10%" linetype 1 linewidth 0.2 pointtype
2 pointsize 0.2 linecolor 2, \
"data_5.txt" title "5%" linetype 1 linewidth 0.2 pointtype
3 pointsize 0.2 linecolor 3, \
"data_2.txt" title "2%" linetype 1 linewidth 0.2 pointtype
4 pointsize 0.2 linecolor 4, \
"data_0.txt" title "0%" linetype 1 linewidth 0.2 pointtype
7 pointsize 0.2 linecolor 7, \
"data_m2.txt" title "-2%" linetype 1 linewidth 0.2 pointtype
4 pointsize 0.2 linecolor 4, \
"data_m5.txt" title "-5%" linetype 1 linewidth 0.2 pointtype
3 pointsize 0.2 linecolor 3, \
"data_m10.txt" title "-10%" linetype 1 linewidth 0.2 pointtype
2 pointsize 0.2 linecolor 2, \
"data_m15.txt" title "-15%" linetype 1 linewidth 0.2 pointtype
1 pointsize 0.2 linecolor 1

##########################################################

Bests,

pem

Vadim Biktashev

unread,
May 1, 2010, 7:50:17 AM5/1/10
to
Thanks - it looks I can reproduce your result now.
The next thing is to understand what exactly do you want to achieve.
Do I understand right that you want to have the keys in two columns (rather than two rows as you say?)
And you want them closer to each other in the vertical direction, right?
Are there any other constraints?
For instance, I have managed to get them closer to each other, and still in two columns, by using

set key box linestyle 1 right top Left reverse samplen 1 spacing 0.5 height 10 width 0

It does not look nice as the letterings from adjacent keys overlap, but may be that is what you need?
If not, then exactly what?

- V

pem wrote:

pem

unread,
May 1, 2010, 8:30:30 AM5/1/10
to
Thanks a lot, Vadim.

On 5月1日, 下午7时50分, Vadim Biktashev <biktas...@ntlworld.com> wrote:
> The next thing is to understand what exactly do you want to achieve.
> Do I understand right that you want to have the keys in two columns (rather than two rows as you say?)

Yes, I mean have the keys in 2 columns. Sorry for the mistake.

> And you want them closer to each other in the vertical direction, right?

Yes.


> Are there any other constraints?
> For instance, I have managed to get them closer to each other, and still in two columns, by using
> set key box linestyle 1 right top Left reverse samplen 1 spacing 0.5 height 10 width 0
> It does not look nice as the letterings from adjacent keys overlap, but may be that is what you need?
> If not, then exactly what?

From the results you can see there are large spacing between *the edge
of the box* and *the keys* in the vetical direction. I expect this
spacing also be decreased. Using "height 10", this spacing become
larger so that the space also becomes larger. I have tried decreaing
the "height", this spacing decrease, that's what I expected. but the
number of columns changes. e.g. when height=3 or smaller, there is
only one column.

I would like there's always two columns in the box, while keeping the
size of the box suit the keys well. If the room in the box are filled
efficiently by the keys, the box can be smaller in the vertical
direction, thus it will not overlap with the curves. I don't know
whether this can be achived in gnuplot.

Bests,

pem


Vadim Biktashev

unread,
May 1, 2010, 9:14:25 AM5/1/10
to
I see.
It appears to me that what you are trying to achieve is actually against the whole gnuplot "set key" philosophy.
The manual explicitly says "Elements within the key are stacked according to vertical or horizontal.
In the case of vertical, the key occupies as few columns as possible.
That is, elements are aligned in a column until running out of vertical space at which point a new column is started.
In the case of horizontal, the key occupies as few rows as possible."
Which means you only managed to get them in two columns by making the required vertical space too big to fit
into the available vertical space, which presumably means the plot height (or may be screen height?)
So when you increase the total height required for the key (9 x height of one entry + the "height" parameter) above plot height,
you get te second column, and when you decrease it back, you get one column again.
Apparently, the gnuplot developers think that they know better how many columns you should have, and it is as small as possible.

The only chance to get what you want would be to try and cheat gnuplot into thinking that it has smaller vertical space for the
key than
it actually has. But I have not been able to do that, so it is cleverer than me. Sorry!

- V.

pem wrote:
> Thanks a lot, Vadim.
>

pem

unread,
May 1, 2010, 11:29:48 AM5/1/10
to
On 5月1日, 下午9时14分, Vadim Biktashev <biktas...@ntlworld.com> wrote:
> The only chance to get what you want would be to try and cheat gnuplot into thinking that
> it has smaller vertical space for the key than it actually has. But I have not been able to do that,
> so it is cleverer than me. Sorry!

Thank you all the same, Vadim.
Maybe I should try post-processing the output in an image editor like
GIMP to achive the effect.

Best,
pem

rusk...@gmail.com

unread,
Nov 14, 2018, 12:55:43 AM11/14/18
to
0 new messages