1

It seems like when plotting to a table the string length of a column is apparently limited to about 62 characters. The code below is a minimal example (gnuplot 5.2.5).

Why is the string length limited to such a "small" value? Is there a way around to be able to use longer strings?

### plot dataset to table including strings
reset session

$DataInput <<EOD
# tab separated data
1   0.123   This is some text, actually a lot of text, which apparently is too much for gnuplot.    84
2   0.456   This is some text, actually a lot of text, which apparently is too much.    72
3   0.789   This is some text, actually a lot of text.  42
EOD

set datafile commentschar ""
set datafile separator "\n"
set table $DataOutput
    plot $DataInput u (stringcolumn(1)) with table
unset table
set datafile separator "\t"
set datafile commentschar "#"

print "DataInput:"
print $DataInput

print "DataOutput:"
print $DataOutput

### end of code

Output:

DataInput:
# tab separated data
1   0.123   This is some text, actually a lot of text, which apparently is too much for gnuplot.    84
2   0.456   This is some text, actually a lot of text, which apparently is too much.    72
3   0.789   This is some text, actually a lot of text.  42

DataOutput:
 # tab separated data   
 1  0.123   This is some text, actually a lot of text, which appar
 2  0.456   This is some text, actually a lot of text, which appar
 3  0.789   This is some text, actually a lot of text.  42

1 Answer 1

2

You have found a bug, or at least an unnecessary limitation. The per-column output length from "plot with table" is limited to the maximum width of the %g format, but that is irrelevant for strings.

Depending on the full use case you might be able to work around the bug by something based on "plot with label". Here is an ugly example to be appended to the end of your sample code:

print "\ndirect output to table with labels"
set table $LabelOutput
    plot $DataInput using (0):(0):(stringcolumn(1)) with labels
unset table
print $LabelOutput

print "\n Edited version"
do for [i=1:|$LabelOutput|] {
    print $LabelOutput[i][1:1], $LabelOutput[i][7:*]
}

Output (yeah, the comments are mangled and I didn't remove the quotes):

direct output to table with labels

# Curve 0 of 1, 4 points
# Curve title: "$DataInput using (0):(0):(stringcolumn(1))"
# x y label type
 0  0 "# tab separated data"
 0  0 "1   0.123   This is some text, actually a lot of text, which apparently is too much for gnuplot.    84"
 0  0 "2   0.456   This is some text, actually a lot of text, which apparently is too much.    72"
 0  0 "3   0.789   This is some text, actually a lot of text.  42"



 Edited version

#e 0 of 1, 4 points
#e title: "$DataInput using (0):(0):(stringcolumn(1))"
#label type
 "# tab separated data"
 "1   0.123   This is some text, actually a lot of text, which apparently is too much for gnuplot.    84"
 "2   0.456   This is some text, actually a lot of text, which apparently is too much.    72"
 "3   0.789   This is some text, actually a lot of text.  42"
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Ethan, I was not aware (or forgot) that you can directly iterate through the lines of a datablock by do for [i=1:|$Data|] { print $Data[i] } (or is it called dataset? I'm confused). Couldn't find this in help, where to find? This basically simplifies one of my intentions to replace strings in a dataset (stackoverflow.com/a/54541838/7295599) and with this plotting strings to a table is actually not needed anymore. So, in a sense question solved (or obsolete) :-) and a "bug" discovered ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.