Hi Troels, Please see below:
I find it very usefull, that xmgrace plots are produced during analysis and the graphs are exported as stand-alone files, so it not necessary to open relax to view the files.
We could do the same with matplotlib, generating SVG files or some other hardcopy version on the fly.
I have never used xmgrace before, but only gnuplot. But it seems that the GUI for xmgrace is a little more intuitive. And they kind-of do the same things. With the latest tweak that plots are also exported to png files, I can quickly go through 100 residues in my folder, and modify a single residue without opening the saved data. That's good.
These additions are quite useful. Note that these were specific to the relax_disp.plot_disp_curves user function and not the more generic grace.write user function used to generate the chi-squared or parameter verses residue/spin number plots.
But it is not good, that I probably sometimes would need to combine some data into one graph. With the current solution, this is not easily done.
This will always be difficult independent of the graphing method. Such cases could therefore be identified and specifically handled. Coming up with a general methodology might be too difficult.
Regarding matplotlib. I am in favor of matplotlib, because it is a plotting language that I understand (python) and I can re-use old plot code, to get the graph I like. And it is in development.
This reusing of your old code, as well as possibly code from Mathilde and Paul, as well as NESSY, would make this much easier to implement. Though if one knows Python and matplotlib, writing everything from scratch, but using the relax code for Grace as a template, this should be relatively trivial.
As relax are now, one should be able to make an external "plot file". And then run the commands via: User functions (n-z) -> script That is how I load my data in. I write a script file, open relax gui, and run the script. In the file, one import matplotlib and write some line to extract data from the the current data pipe "cdp". For example data for 1-3 residues. I am still looking into, how to extract relevant data from the data pipe. http://nmr-relax.kimlinnet.dk/index.php?title=Category:List_objects And then just write some matplotlib commands to plot it.
I do not believe that this would be the optimal solution - it would require more work to implement it and doesn't fit well with the current relax design. For the simplest and quickest implementation, I would suggest using the current relax_disp.plot_disp_curves user function. We then add an option for chosing between Grace and matplotlib. If the user chooses matplotlib but the matplotlib Python module is not available, then a RelaxError is thrown explaining the problem. The plots would then be automatically created by relax on the fly. For the user function backend, the code would be the script you suggest. Instead of generating a script and writing it to the output directory, that code could be instead permanently in the plot_disp_curves() function of specific_analyses/relax_disp/disp_data.py and a new lib/software/matplotlib.py file, just as is currently done with Grace. The first module already deals with the relax data store and the assembly of data from it (specifically the current data pipe, or cdp data structure). This then passes the assembled data to the second module to generate the plots. One question is, what should the hardcopy output format from matplotlib be? Maybe the different options could be presented to the user? Though a default format would need to be chosen for the relaxation dispersion auto-analysis. Using matplotlib for the plots of parameter values and chi-squared value verses the residue sequence would use the same code in lib.software.matplotlib. But instead this would be called from code in a new module pipe_control.matplotlib, which mimics that of the pipe_control.grace module. This would require a new user function called matplotlib.write, again mimicking the grace.write user function (i.e. copy file + slightly modify).
For a future user friendly GUI solution, I imagine a menu where one can select some template matplotlib functions. Then modify them in a wxpython text editor or OS editor, and then save them in the relax folder, or in $HOME/.relax/xxx or in the current working directory. And then of course push a "execute" button.
The above idea handles this elegantly. The only user visible difference is a single option for the relax_disp.plot_disp_curves user function. However the user in the GUI would probably always use the relaxation dispersion auto-analysis which will call this function for the user for each model optimised. Therefore the user will only see the new matplotlib hardcopy images being dumped into the 'matplotlib' directory for the current optimised model.
Another possibility would also just be, to have a matplotlib script collection on the wiki.
I think having it in the relax backend would be a better option for such code. The problem is that relax changes incredibly quickly, and any scripts touching the relax data store would have a half-life measured in months (scripts which use the user functions instead can last for years without modification). If the code is part of relax, we can add tests to the test suite to be sure that the code operates bug-free forever. Then if there are any internal data structure changes in the future, the matplotlib code can be instantly fixed. Cheers, Edward