How to use substrings in gnuplot -


i'd plot datafile using substrings column. data file contains data in format

1 (15, 3): dx: -1.619, dy: 3.315, dxsc: 0.981, dysc: 0.993 2 ( 4,16): dx: -0.540, dy: -0.540, dxsc: 0.992, dysc: 0.977 ... 

and i'd plot numbers between brackets (x,y) y against x, like:

plot "data.dat" u substr(($2),7,8 ):substr(($2),10,11) 

what correct syntax this?

doing gnuplot bit tricky, because gnuplot doesn't allow specifying arbitrary format input. usually, best way use external tool extract data , feed resulting file gnuplot (this done on-the-fly using syntax (plot '< script data.dat'...).

however, in case there hack working gnuplot following next steps:

  • use set datafile separator ':' have information of both x , y in single column.
  • use strstrt determine start , end string positions of x , y values.

    for x-value be

    substr(s, strstrt(s, "(")+1, strstrt(s, ",")-1) 
  • add 0.0 resulting substrings have them implicitely converted real values.

a complete script, works example data is

set datafile separator ":" get_x(c) = 0.0 + substr(strcol(c), strstrt(strcol(c), "(") + 1, strstrt(strcol(c), ",") - 1) get_y(c) = 0.0 + substr(strcol(c), strstrt(strcol(c), ",") + 1, strstrt(strcol(c), ")") - 1)  plot 'data.dat' using (get_x(1)):(get_y(1)) points pt 7 ps 2 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -