mailr27128 - in /trunk/lib/plotting: __init__.py api.py gnuplot.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on December 18, 2014 - 12:07:
Author: bugman
Date: Thu Dec 18 12:07:24 2014
New Revision: 27128

URL: http://svn.gna.org/viewcvs/relax?rev=27128&view=rev
Log:
Implemented a very basic gnuplot backend for the correlation_matrix() 
plotting API function.

This is in the new lib.plotting.gnuplot module.  It creates an incredibly 
basic gnuplot script for
visualising the correlation matrix, assuming a text file has already been 
created.


Added:
    trunk/lib/plotting/gnuplot.py
Modified:
    trunk/lib/plotting/__init__.py
    trunk/lib/plotting/api.py

Modified: trunk/lib/plotting/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/plotting/__init__.py?rev=27128&r1=27127&r2=27128&view=diff
==============================================================================
--- trunk/lib/plotting/__init__.py      (original)
+++ trunk/lib/plotting/__init__.py      Thu Dec 18 12:07:24 2014
@@ -24,5 +24,6 @@
 
 # The package content list.
 __all__ = [
-    'api'
+    'api',
+    'gnuplot'
 ]

Modified: trunk/lib/plotting/api.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/plotting/api.py?rev=27128&r1=27127&r2=27128&view=diff
==============================================================================
--- trunk/lib/plotting/api.py   (original)
+++ trunk/lib/plotting/api.py   Thu Dec 18 12:07:24 2014
@@ -24,6 +24,7 @@
 
 # relax module imports.
 from lib.errors import RelaxError
+from lib.plotting import gnuplot
 
 
 def correlation_matrix(format=None, matrix=None, labels=None, file=None, 
dir=None, force=False):
@@ -43,6 +44,7 @@
 
     # The supported formats.
     function = {
+        'gnuplot': gnuplot.correlation_matrix
     }
 
     # Unsupported format.

Added: trunk/lib/plotting/gnuplot.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/plotting/gnuplot.py?rev=27128&view=auto
==============================================================================
--- trunk/lib/plotting/gnuplot.py       (added)
+++ trunk/lib/plotting/gnuplot.py       Thu Dec 18 12:07:24 2014
@@ -0,0 +1,55 @@
+###############################################################################
+#                                                                            
 #
+# Copyright (C) 2014 Edward d'Auvergne                                       
 #
+#                                                                            
 #
+# This file is part of the program relax (http://www.nmr-relax.com).         
 #
+#                                                                            
 #
+# This program is free software: you can redistribute it and/or modify       
 #
+# it under the terms of the GNU General Public License as published by       
 #
+# the Free Software Foundation, either version 3 of the License, or          
 #
+# (at your option) any later version.                                        
 #
+#                                                                            
 #
+# This program is distributed in the hope that it will be useful,            
 #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of             
 #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              
 #
+# GNU General Public License for more details.                               
 #
+#                                                                            
 #
+# You should have received a copy of the GNU General Public License          
 #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.      
 #
+#                                                                            
 #
+###############################################################################
+
+# Module docstring.
+"""Module for data plotting using gnuplot."""
+
+# relax module imports.
+from lib.io import open_write_file, swap_extension
+
+
+def correlation_matrix(matrix=None, labels=None, file=None, dir=None, 
force=False):
+    """Gnuplot plotting function for representing correlation matrices.
+
+    @keyword matrix:    The correlation matrix.  This must be a square 
matrix.
+    @type matrix:       numpy rank-2 array.
+    @keyword labels:    The labels for each element of the matrix.  The same 
label is assumed for each [i, i] pair in the matrix.
+    @type labels:       list of str
+    @keyword file:      The name of the file to create.
+    @type file:         str
+    @keyword dir:       The directory where the PDB file will be placed.  If 
set to None, then the file will be placed in the current directory.
+    @type dir:          str or None
+    """
+
+    # The script file name.
+    file_name = swap_extension(file=file, ext='gnu')
+
+    # Open the script file for writing.
+    output = open_write_file(file_name, dir=dir, force=force)
+
+    # Set the plot type.
+    output.write("set pm3d map\n")
+
+    # Load and show the text data.
+    output.write("splot \"%s\" matrix\n" % file)
+
+    # Close the file.
+    output.close()




Related Messages


Powered by MHonArc, Updated Thu Dec 18 12:20:03 2014