Search code examples
gnuplot

What is the max number of data points for gnuplot and how can it be changed?


I have a file with 2 columns and 20567 lines.

executing plot videoonly.csv gives me this graph with data points all over the place

output1

after executing

sort -t, -k1,1 -n videoonly.csv  -o videonlyxascending.csv

in terminal, executing

plot videonlyxascending.csv

in gnuplot gives me this graph, with has an exponential shape:

output2

after executing

sort -t, -k1,1 -n videoonly.csv  -o videonlyxascendingr.csv

in terminal, executing

plot 'videonlyxascendingr.csv

gives me this graph with an 1/x shape:

output3

The only conclusion I can draw from this is that there must be a limit to the max number of data points that can be plotted in gnuplot. How do I remove or change this limit? My aim is to plot all 20567 sets of coordinates.

I intentionally included all the CLI here in case I missed out something on that front.

Edit: added the head of each file as requested:

head videoonly.csv 
8998,1199.343547
7197,5617.624526
14030,718733.5968
493,35538.03271
244,3628252.788
1552634,38232.26264
11517369,3749992.891
24334184,41001712.28
10602194,32337792.97
39578,170894.6336

head videonlyxascending.csv 
40,1.936762
40,10.459237
40,10.666329 
40,12.175943
40,1494.510011
40,2621.55409
40,3.047611
40,3.047644
40,3.047658

head videonlyxascendingr.csv  
336988948,84578448.32
242183310,181449238.6
241991847,621259555.7
218954629,75660772.89
217948201,322373455.9
202997812,166966561.1
197204299,87386448.34
193837459,155752095.2 

Solution

  • I think there are two issues in this case. The ordering the the number of columns gnuplot is seeing in the file. As far as I understand, when gnuplot sees only one column in the input, it plots it as a sequence, and does not change the order. I suspect you are not telling gnuplot that your input file is a csv. By doing:

    plot '<jot 1000'     #sorted list of 1000 numbers
    plot '<jot -r 1000'  #shuffled list of 1000 numbers
    

    output 1

    Which is exactly what you see. Now consider the input file:

    1,1
    4,4
    3,3
    5,5
    2,2
    9,9
    8,8
    6,6
    7,7
    

    By doing:

    unset key
    plot 'tmp'
    set datafile separator ','
    plot 'tmp'
    

    enter image description here

    When gnuplot sees two columns (after telling it that the separator is ,), the order does not matter.