![]() This skips error processing and such, but on a GNU/Linux or Unix machine this should generate around 30 000, frames in about three minutes albeit the plot is relatively basic (a polyline with 300 points) … program gnuplotexampleĬharacter(len=*),parameter :: g='(*(g0,1x))'Ĭall execute_command_line('mkfifo GNUPLOT.in')Ĭall execute_command_line('gnuplot -persist < GNUPLOT.in',wait=.false.) Usind the gnuplot here documents for the data and an optional “stats $set1 using 1:2” and such, and being able to change the plot options from other processes writing to the FIFO file was handy did that with other line mode commands too mkfifo is a very underused command and can be used in a safer manner than some for allowing multiple user to input into a process running under another ID and so on. Later we changed it to to do a popen by calling the C routine and that worked even better and options for pausing and sleeping between frames and such as mentioned above. If can be very fast on an X11 with backing store (very common now-adays). >set title " example of gnuplot data and command file generation" Looks like you have a solution, but on GNU/Linux and Linux machines we used to do this a lot for quick and dirty plotting, where you could just create a FIFO file with “mkfifo GNUPLOT.fifo” and then start a “gnuplot set terminal x11 (179) RPEM + Gnuplot display LL in real time - YouTube Here is an example of my code running while display the LL vs iteration in real time, Set style line 102 lc rgb "#d6d7d9" lt 0 lw 1 Set style line 7 lc rgb "#9400d3" lt 1 lw 2 Set style line 6 lc rgb "#0000ff" lt 1 lw 2 Set style line 5 lc rgb "#006400" lt 1 lw 2 Set style line 4 lc rgb "#ffa500" lt 1 lw 2 Set style line 3 lc rgb "#ff4500" lt 1 lw 2 Set style line 2 lc rgb "#ff0000" lt 1 lw 2 Set style line 1 lc rgb "#800000" lt 1 lw 2 Set term wxt size 1024,768 enhanced font "verdana,10" title "ogpf libray: Rev. Where ‘ogpf_temp_script.gp’ is my Gnuplot scipt, which I just use the one generated by ogpf library, but I added pause 1Īt the end, it read the data from my output file which is called LL_iter.txt, it monitors the Log likelihood (LL). I added command, call execute_command_line ('wgnuplot -persist ' // 'ogpf_temp_script.gp', wait =. ![]() ![]() There is a reason people just save all the results, plot them with gnuplot, then create an animation using external software such as gimp or imagemagick. ![]() Unless you have serious, time consuming computations needed to be done in each loop iteration, you wouldn’t see any animation since the frames would be plotted very quickly, so you would have to sleep your program in each iteration to actually see any frame. Last but not least, I am not sure all this is worth the effort. Both can be used in your program as a Fortran module, so you can be more interactive without the hassle of relying on system commands. If I wanted to do something like this, I would definitely look for other, more promising solutions: PLplot comes to mind first (alone or with gtk-fortran), or Dislin. Using gnuplot within a Fortran program is perfectly ok if you just want to plot some results, but becomes unnecessarily complicated when it comes to animations. But it is not ideal for what you want to do, because gnuplot is external software that has nothing to do with Fortran. Don’t get me wrong, gnuplot is excellent software, I use it all the time. However, I wouldn’t call any of the above an elegant solution. I played with streams in the past, and I got the result I wanted, but in the end I wasn’t sure I prefer this solution over the others, even though in theory it is more “robust”. This can be done in several ways, but the outline of the method is described here (although this is in Pearl). More sophisticated but also more complicated. This involves GNU/Linux commands such as awk, again called in your program with the system command. (2) Alternatively, you can just save all your data once, then in each iteration use a gnuplot script to plot part of it. For this to look nice you should also know the x and y range of the plot ( maxval(x) and maxval(y)), and use them each time for each plot. It should clear the screen and plot on the same window each iteration. The gnuplot script can be easily created with standard Fortran open, write, and close commands. (1) Create and save a gnuplot script in each iteration as well as the data from x(1) to x(i), then run the script (say, foo.plt) with call system('gnuplot -p foo.plt' ). I can think of at least three ways to do this, although I doubt it is worth the effort.
0 Comments
Leave a Reply. |