Ah, there is one step I forgot about. The Grace graph generation happens in lib.software.grace module whereas the assembly of data from the relax data pipe happens in the pipe_control.grace module. Therefore the missing step is: 6) Matplotlib interface. Create a new module lib.software.matplotlib. This is where matplotlib is imported and the plots are produced and saved. The lib.software.grace module should not be copied as the functions in lib.software.matplotlib would be completely different. But the write_xy_data() and write_xy_header() functions can be used as inspiration. As matplotlib does not appear to have a header from data separation, then maybe on write_xy() function can be written for 2D xy data plots. A different function for 3D data could be created as maybe write_3D(). Note that at some point in the future, the plotting modules in lib.software might shift to lib.plotting. Regards, Edward On 27 March 2014 10:28, Edward d'Auvergne <edward@xxxxxxxxxxxxx> wrote:
Hi, The following is planning document for adding support for matplotlib graphing to relax. The plan will be broken into a few simple steps: 1) Module detection. Firstly the dep_check module would need to be modified to detect the presence of the matplotlib Python package. In addition, the package_info() method in the 'info' module should be changed to print out if matplotlib is present and which version is present (matplotlib.__version__). Then matplotlib will be shown when running relax with the --info command line option. 2) Icons For the GUI and the user manual, icons are needed. These can be taken from the matlplotlib sources and added to the graphics/relax_icons/ directories. The 16x16, 24x24, 32x32, and 48x48 icons could be taken from the ./doc/_static/favicon.ico file, specifically layers #4, #5, and #6. The 128x128 icon used in the manual could be regenerated using the matplotlib graphic script ./examples/api/logo2.py, but with the text removed. 3) Uf frontend. For this, the user_functions.grace module can be copied and modified to change all instances of 'grace' with 'matplotlib'. So the user functions would be matplotlib.view and matplotlib.write. New user functions could be added later on if additional functionality from matplotlib is desired. 4) Uf backend. The pipe_control.grace module can be copied to pipe_control.matplotlib and changed as needed. The key functions are view() and write() as these are used by the user function frontends. All other functions can be added as needed to simplify the matplotlib graph generation (and the old ones form grace deleted). 5) Saving format. Do we output in SVG or PNG? I don't know matplotlib, but is there a way of saving a matplotlib native file format so it can be modified later? The options should be available as arguments to the matplotlib.write user function. Completion of these steps is sufficient for full matplotlib support within relax. Then adding the plotting as default for the auto-analyses would be trivial. Regards, Edward