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

xticlabels format

851 views
Skip to first unread message

ginginsman

unread,
Feb 14, 2010, 9:57:23 AM2/14/10
to
Using data from a column works nicely "plot mygraph using
1:2 :xticlabels(3)", for example. But is there any way I can add a
string or a second column into the xticlabels? For example, to
concatenate columns 3 and 4: "plot mygraph using 1:2 :xticlabels(3:4)"
or column 3 plus a string?

Also, can you somehow add a CRLF in order to display two data items
one above the other at a xticlabel point: the time (CRLF) and a column
data item, for example? Or is there a better way to display such
information below the x-axis?

sfeam

unread,
Feb 14, 2010, 3:38:08 PM2/14/10
to
ginginsman wrote:

> Using data from a column works nicely "plot mygraph using
> 1:2 :xticlabels(3)", for example. But is there any way I can add a
> string or a second column into the xticlabels?

Apologies for poor documentation; this section has been expanded
in the 4.4 docs.

The xticlabels command expects a string-valued function.
"using 1:2:xticlabels(3)" is simply a convenient shorthand for
"using (column(1)):(column(2)):xticlabels(stringcolumn(3))

stringcolumn(3) can also be abbreviated as strcol(3)


> For example, to
> concatenate columns 3 and 4: "plot mygraph using 1:2 :xticlabels(3:4)"
> or column 3 plus a string?

mylabel(col1,col2) = sprintf("%s %s MORE TEXT",strcol(col1),strcol(col2))
plot mygraph using 1:2:xticlabels( mylabel(3,4) )

> Also, can you somehow add a CRLF in order to display two data items
> one above the other at a xticlabel point

mylabel(col1,col2) = sprintf("%s\n"%s",strcol(col1),strcol(col2))

ginginsman

unread,
Feb 15, 2010, 6:13:34 AM2/15/10
to
On Feb 14, 9:38 pm, sfeam <sf...@users.sourceforge.net> wrote:
> ginginsman wrote:
> > Using data from a column works nicely "plot mygraph using
> > 1:2 :xticlabels(3)", for example. But is there any way I can add a
> > string or a second column into the xticlabels?
>
> Apologies for poor documentation; this section has been expanded
> in the 4.4 docs.
>
> > Also, can you somehow add a CRLF in order to display two data items
> > one above the other at a xticlabel point
>
> mylabel(col1,col2) = sprintf("%s\n"%s",strcol(col1),strcol(col2))
>

No apologies called for.

I cannot seem to get the \n to work as shown. Any further pointers?

Many thanks for the pointers.

sfeam

unread,
Feb 15, 2010, 1:24:19 PM2/15/10
to
ginginsman wrote:

Is it possible that the second line of your labels has gone off the
bottom of the plot? You may have to reserve extra room underneath
the plot for your multi-line labels:
set bmargin 4
or
set bargin at screen 0.1

ginginsman

unread,
Feb 15, 2010, 3:29:53 PM2/15/10
to
On Feb 15, 7:24 pm, sfeam <sf...@users.sourceforge.net> wrote:
> ginginsman wrote:
> > On Feb 14, 9:38 pm, sfeam <sf...@users.sourceforge.net> wrote:
> >> ginginsman wrote:
> >> > Using data from a column works nicely "plot mygraph using
> >> > 1:2 :xticlabels(3)", for example. But is there any way I can add a
> >> > string or a second column into the xticlabels?
>
> >> > Also, can you somehow add a CRLF in order to display two data items
> >> > one above the other at a xticlabel point
>
> >> mylabel(col1,col2) = sprintf("%s\n"%s",strcol(col1),strcol(col2))
>
> > I cannot seem to get the \n to work as shown. Any further pointers?
>
> Is it possible that the second line of your labels has gone off the
> bottom of the plot?   You may have to reserve extra room underneath
> the plot for your multi-line labels:
>    set bmargin 4
> or
>    set bargin at screen 0.1

I'll check but I don't think so. The second line is in the same
horizontal position.

I'll try the margin settings, thanks.

ginginsman

unread,
Feb 18, 2010, 8:31:58 AM2/18/10
to
On Feb 15, 9:29 pm, ginginsman <d...@suiattle.org> wrote:
> On Feb 15, 7:24 pm, sfeam <sf...@users.sourceforge.net> wrote:
>
>
>
>
>
> > ginginsman wrote:
> > > On Feb 14, 9:38 pm, sfeam <sf...@users.sourceforge.net> wrote:
> > >> ginginsman wrote:
> > >> > Using data from a column works nicely "plot mygraph using
> > >> > 1:2 :xticlabels(3)", for example. But is there any way I can add a
> > >> > string or a second column into the xticlabels?
>
> > >> > Also, can you somehow add a CRLF in order to display two data items
> > >> > one above the other at a xticlabel point
>
> > >> mylabel(col1,col2) = sprintf("%s\n"%s",strcol(col1),strcol(col2))
>
> > > I cannot seem to get the \n to work as shown. Any further pointers?
>

When trying to add the \n gnuplot complains a ' ) ' is missing:

mylabel(col1,col2) = sprintf("%s\n"%s",strcol(col1),strcol(col2))

^
')' expected

and no matter what I do with extra ( or ) it doesn't like it.

using bash on OSX 10.6.2, iMac 24" Intel Core 2 Duo 2.8 ghz

ginginsman

unread,
Feb 18, 2010, 8:35:32 AM2/18/10
to

Sorry, copy and paste didn't work. The ^ is directly under the quotes
after the second %s.

Christoph Bersch

unread,
Feb 18, 2010, 8:35:49 AM2/18/10
to
ginginsman wrote:
>
> When trying to add the \n gnuplot complains a ' ) ' is missing:
>
> mylabel(col1,col2) = sprintf("%s\n"%s",strcol(col1),strcol(col2))
^^
Remove that quotation mark!

mylabel(col1,col2) = sprintf("%s\n%s",strcol(col1),strcol(col2))

Christoph

ginginsman

unread,
Feb 18, 2010, 8:42:49 AM2/18/10
to

That was it, and had just tried it as you posted.

mylabel(col1,col2) = sprintf("%s \n%s",strcol(col1),strcol(col2))

Thanks for the assistance and apologies for all replies to self!

ginginsman

unread,
Feb 23, 2010, 4:23:01 AM2/23/10
to
On Feb 14, 9:38 pm, sfeam <sf...@users.sourceforge.net> wrote:
> ginginsman wrote:
> > Using data from a column works nicely "plot mygraph using
> > 1:2 :xticlabels(3)", for example. But is there any way I can add a
> > string or a second column into the xticlabels?
>
> Apologies for poor documentation; this section has been expanded
> in the 4.4 docs.
>
> The xticlabels command expects a string-valued function.
> "using 1:2:xticlabels(3)" is simply a convenient shorthand for
> "using (column(1)):(column(2)):xticlabels(stringcolumn(3))
>
> stringcolumn(3) can also be abbreviated as strcol(3)
>
> > For example, to
> > concatenate columns 3 and 4: "plot mygraph using 1:2 :xticlabels(3:4)"
> > or column 3 plus a string?
>
>  mylabel(col1,col2) = sprintf("%s %s MORE TEXT",strcol(col1),strcol(col2))
>  plot mygraph using 1:2:xticlabels( mylabel(3,4) )
>
> > Also, can you somehow add a CRLF in order to display two data items
> > one above the other at a xticlabel point
>
> mylabel(col1,col2) = sprintf("%s\n"%s",strcol(col1),strcol(col2))
>

With the data file containing lines like this:

2010/02/01-12:18 11.39 11.39 H

and using:


mylabel(col1,col2) = sprintf("%s\n"%s",strcol(col1),strcol(col2))

plot mygraph using 1:2:xticlabels( mylabel(3,4) )

I keep getting this error:

f_sprintf: attempt to print numeric value with string format

This works fine with either 3 or 4:
plot mygraph using 1:2:xticlabels(4)

so it doesn't complain if I use a numeric value in the xticlabels
declaration.

What am I missing?

sfeam

unread,
Feb 23, 2010, 11:58:54 PM2/23/10
to
ginginsman wrote:

>
> With the data file containing lines like this:
>
> 2010/02/01-12:18 11.39 11.39 H
>
> and using:
> mylabel(col1,col2) = sprintf("%s\n"%s",strcol(col1),strcol(col2))

^^^


> plot mygraph using 1:2:xticlabels( mylabel(3,4) )
>
> I keep getting this error:
>
> f_sprintf: attempt to print numeric value with string format

After removing the extraneous " mark in the format command,
the commands above work fine for me with your test data line.

ginginsman

unread,
Feb 24, 2010, 4:05:36 AM2/24/10
to
On Feb 24, 5:58 am, sfeam <sf...@users.sourceforge.net> wrote:
> ginginsman wrote:
>
> > With the data file containing lines like this:
>
> > 2010/02/01-12:18   11.39   11.39   H
>
> > and using:
> > mylabel(col1,col2) = sprintf("%s\n"%s",strcol(col1),strcol(col2))
>
>                                    ^^^
> > plot mygraph using 1:2:xticlabels( mylabel(3,4) )
>
> > I keep getting this error:
>
> > f_sprintf: attempt to print numeric value with string format
>
> After removing the extraneous " mark in the format command,
> the commands above work fine for me with your test data line.

I need my eyes checked! I had fixed that and copied the wrong line -
apologies.

BUT, in a file with data like the above, but with empty values in
columns 3 and 4, for example:

2010/02/03-20:12 -0.88 -0.89 L
2010/02/04-02:30 10.44 10.44 H
2010/02/04-08:48 -0.65
2010/02/04-15:00 9.6 9.6 H
2010/02/04-21:06 -0.22

is there a way to tell gnuplot to ignore the empty values or do I have
to fill those holes with a ' ? ' or similar? Those empty values are
causing gnuplot to throw that same error.

0 new messages