I ran into a problem plotting with python in windows. I don't know how common this problem is, but here were a few articles about it. 2 problems
First: matplotlib would crash (not respond) when trying to update the plot in a loop so that I could visualize data as it's generated.
Second: because windows command prompt doesn't play well with -persist, the well-known Gnuplot.py couldn't open a figure, display the data, then continue the code without closing the figure. The figure has to be manually closed (or closed from command or not using persist) before the code would continue. The other option is to use the png terminal to generate a png image that can be viewed outside either python or gnuplot.
This gave me an idea - but not for python. In windows, windows photo viewer automatically updates if the image it's viewing is updated. So I thought, why not generate a single png file that is viewed in windows photo viewer and let windows photo viewer update the image in real time. This works as long as the png can be written and viewed before the next one is written.
So if I can do this with python, why couldn't I do it in Fortran too?
Here's my idea: Make a module that has two functions. First, one that takes variable arguments with column data and parses it in the correct form for gnuplot csv ( columns next to each other for each variable) and writes the data to a .dat file. The second takes data and a gnuplot script name and calls the first to generate the correct data and then executes the load 'gnuscript.txt' command.
This is a bit redundant in python but I decided to use it as a first step towards something better. Since fortran doesn't visualize data on any operating system (easily at least), this approach would be extensible to other OS.
Attached is a python collection with gnuplot scripts to generate several common figures.
GnuPlotLib.zip
Thursday, August 6, 2015
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment