mailr23166 - /trunk/lib/software/grace.py


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

Header


Content

Posted by edward on May 14, 2014 - 11:09:
Author: bugman
Date: Wed May 14 11:09:37 2014
New Revision: 23166

URL: http://svn.gna.org/viewcvs/relax?rev=23166&view=rev
Log:
Advances to the Grace 2D plotting abilities in the lib.software.grace relax 
library module.

The write_xy_header() function now accepts the new 'world', 
'tick_major_spacing', and
'tick_minor_count' arguments.  These allow the world view to be preset, and 
allow the ticks on the
X and Y-axes to be programatically changed.  The write_xy_data() has also 
been modified so that the
autoscaling can be turned off, as this Grace command will overwrite the world 
view and tick setup.


Modified:
    trunk/lib/software/grace.py

Modified: trunk/lib/software/grace.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/software/grace.py?rev=23166&r1=23165&r2=23166&view=diff
==============================================================================
--- trunk/lib/software/grace.py (original)
+++ trunk/lib/software/grace.py Wed May 14 11:09:37 2014
@@ -120,7 +120,7 @@
     file.write("        return_code = subprocess.call(im_args)\n")
 
 
-def write_xy_data(data, file=None, graph_type=None, norm=None):
+def write_xy_data(data, file=None, graph_type=None, norm=None, 
autoscale=True):
     """Write the data into the Grace xy-scatter plot.
 
     The numerical data should be supplied as a 4 dimensional list or array 
object.  The first dimension corresponds to the graphs, Gx.  The second 
corresponds the sets of each graph, Sx.  The third corresponds to the data 
series (i.e. each data point).  The forth is a list of the information about 
each point, it is a list where the first element is the x value, the second 
is the y value, the third is the optional dx or dy error (either dx or dy 
dependent upon the graph_type arg), and the forth is the optional dy error 
when graph_type is xydxdy (the third position is then dx).
@@ -134,6 +134,8 @@
     @type graph_type:       str
     @keyword norm:          The normalisation flag which if set to True will 
cause all graphs to be normalised to 1.  The first dimension is the graph.
     @type norm:             None or list of bool
+    @keyword autoscale:     A flag which if True will cause the world view 
of each graph to be autoscaled (by placing the Grace command "@autoscale" at 
the end of the file).  If you have supplied a world view for the header or 
the tick spacing, this argument should be set to False to prevent that world 
view from being overwritten.
+    @type autoscale:        bool
     """
 
     # Graph number.
@@ -207,9 +209,10 @@
             file.write("&\n")
 
     # Autoscaling of all graphs to avoid user confusion.
-    for i in range(graph_num):
-        file.write("@with g%i\n" % i)
-        file.write("@autoscale\n")
+    if autoscale:
+        for i in range(graph_num):
+            file.write("@with g%i\n" % i)
+            file.write("@autoscale\n")
 
     # Auto-arrange the graphs if multiple are present.
     if len(data) > 1:
@@ -218,7 +221,7 @@
         file.write("@arrange(%i, %i, .1, .1, .1, OFF, OFF, OFF)\n" % 
(row_num, col_num))
 
 
-def write_xy_header(file=None, paper_size='A4', title=None, subtitle=None, 
view=None, graph_num=1, sets=None, set_names=None, set_colours=None, 
x_axis_type_zero=None, y_axis_type_zero=None, symbols=None, 
symbol_sizes=None, symbol_fill=None, linestyle=None, linetype=None, 
linewidth=None, data_type=None, seq_type=None, axis_labels=None, legend=None, 
legend_pos=None, legend_box_fill_pattern=None, legend_char_size=None, 
norm=None):
+def write_xy_header(file=None, paper_size='A4', title=None, subtitle=None, 
world=None, view=None, graph_num=1, sets=None, set_names=None, 
set_colours=None, x_axis_type_zero=None, y_axis_type_zero=None, symbols=None, 
symbol_sizes=None, symbol_fill=None, linestyle=None, linetype=None, 
linewidth=None, data_type=None, seq_type=None, axis_labels=None, 
tick_major_spacing=None, tick_minor_count=None, legend=None, legend_pos=None, 
legend_box_fill_pattern=None, legend_char_size=None, norm=None):
     """Write the grace header for xy-scatter plots.
 
     Many of these keyword arguments should be supplied in a [X, Y] list 
format, where the first element corresponds to the X data, and the second the 
Y data.  Defaults will be used for any non-supplied args (or lists with 
elements set to None).
@@ -232,6 +235,8 @@
     @type title:                        None or str
     @keyword subtitle:                  The sub-title of the graph.
     @type subtitle:                     None or str
+    @keyword world:                     The Grace plot default zoom.  This 
consists of a list of the X-axis minimum, Y-axis minimum, X-axis maximum, and 
Y-axis maximum values.  Each graph should supply its own world view.
+    @type world:                        Nor or list of list of numbers
     @keyword view:                      List of 4 coordinates defining the 
graph view port.
     @type view:                         None or list of float
     @keyword graph_num:                 The total number of graphs.
@@ -262,6 +267,10 @@
     @type data_type:                    None or list of list of str
     @keyword seq_type:                  The sequence data type (in the [X, 
Y] list format).  This is for molecular sequence specific data and can be one 
of 'res', 'spin', or 'mixed'.
     @type seq_type:                     None or list of list of str
+    @keyword tick_major_spacing:        The spacing between major ticks.  
This is in the [X, Y] list format whereby the first dimension corresponds to 
the graph number.
+    @type tick_major_spacing:           None or list of list of numbers
+    @keyword tick_minor_count:          The number of minor ticks between 
the major ticks.  This is in the [X, Y] list format whereby the first 
dimension corresponds to the graph number.
+    @type tick_minor_count:             None or list of list of int
     @keyword axis_labels:               The labels for the axes (in the [X, 
Y] list format).  The first dimension is the graph.
     @type axis_labels:                  None or list of list of str
     @keyword legend:                    If True, the legend will be visible. 
 The first dimension is the graph.
@@ -332,6 +341,10 @@
         # Graph Gi.
         file.write("@with g%i\n" % gi)
 
+        # The world view.
+        if world:
+            file.write("@    world %s, %s, %s, %s\n" % (world[gi][0], 
world[gi][1], world[gi][2], world[gi][3]))
+
         # The view port.
         if not view:
             view = [0.15, 0.15, 1.28, 0.85]
@@ -376,8 +389,12 @@
             if axis_labels[gi][i]:
                 file.write("@    %saxis  label \"%s\"\n" % (axes[i], 
axis_labels[gi][i]))
             file.write("@    %saxis  label char size 1.00\n" % axes[i])
+            if tick_major_spacing != None:
+                file.write("@    %saxis  tick major %s\n" % (axes[i], 
tick_major_spacing[gi][i]))
             file.write("@    %saxis  tick major size 0.50\n" % axes[i])
             file.write("@    %saxis  tick major linewidth %s\n" % (axes[i], 
linewidth[gi]))
+            if tick_minor_count != None:
+                file.write("@    %saxis  tick minor ticks %s\n" % (axes[i], 
tick_minor_count[gi][i]))
             file.write("@    %saxis  tick minor linewidth %s\n" % (axes[i], 
linewidth[gi]))
             file.write("@    %saxis  tick minor size 0.25\n" % axes[i])
             file.write("@    %saxis  ticklabel char size 0.70\n" % axes[i])




Related Messages


Powered by MHonArc, Updated Wed May 14 11:20:02 2014