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?
> 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))
No apologies called for.
I cannot seem to get the \n to work as shown. Any further pointers?
Many thanks for the 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.
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
Sorry, copy and paste didn't work. The ^ is directly under the quotes
after the second %s.
mylabel(col1,col2) = sprintf("%s\n%s",strcol(col1),strcol(col2))
Christoph
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!
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?
>
> 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.