2

I need to plot iteration (not i) versus f(i) in row 2 of each 2nd block. I marked the values with '*'. I tried to come up with some solution using 'every' but could not figure out how to plot data from two separate blocks against one another. There are multiple blocks that proceed with this pattern. I chose to only show 1 repetition. It is a last resort option to reformat the data. I would like to devise a way to plot the data in the current format. Can anyone offer some insight?

 i     f(i)       x(i)    iteration =   0*

 1  0.000E+00  1.478E-02  Vlnp                                    
 2 -1.000E-06* 7.352E-01  Vvnp                                    
 3  0.000E+00  7.512E-01  rhovnp                                  
 4 -9.721E-01  9.180E+02  Pnp                                     
 5  9.721E-01  4.380E+06  hvnp                                    
 6  1.000E-06  1.000E-06  mdevap                                  

 i     f(i)       x(i)    iteration =   1*

 1 -2.776E-17 -1.265E+02  Vlnp                                    
 2  1.985E-10* 1.273E+02  Vvnp                                    
 3 -1.224E-03  4.292E+03  rhovnp                                  
 4 -9.983E-01  9.180E+02  Pnp                                     
 5  1.018E+00 -2.560E+10  hvnp                                    
 6  4.468E-08  3.250E+06  mdevap                                  

1 Answer 1

1

I highly recommend to restructure your data. That can be done also inline in gnuplot using tools as grep, awk and sed. This is a working example.

 plot "< grep '*' kxkdata | awk '/^ i/ {printf $6\" \"} /^ 2/ {print $2}' | sed 's/\*//g'"

Basically < means to read from a kind of subshell (I called your file kxk7607). For the usage of the command line tools, you can find information online.

Sign up to request clarification or add additional context in comments.

3 Comments

Let me make sure I understand. I can reformat the data using gnuplot commands? If reformatting is the only option, I may look at my format statements in the source code that generates the output and attempt to reformat the data that way.
No. You can reformat using command-line tools. You can access the command-line tools from within Gnuplot, so you don't necessarily need to change the input file.
I ended up restructuring the file I was plotting. Thank you for your advice , Bernhard.

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.