Package lib :: Package plotting :: Module grace
[hide private]
[frames] | no frames]

Module grace

source code

Module for interfacing with Grace (also known as Xmgrace, Xmgr, and ace).

Functions [hide private]
 
create_grace2images(dir=None)
Create the grace2images.py executable script.
source code
 
script_grace2images(file=None)
Write a python "grace to PNG/EPS/SVG..." conversion script..
source code
 
write_xy_data(data, file=None, graph_type=None, norm_type='first', norm=None, autoscale=True)
Write the data into the Grace xy-scatter plot.
source code
 
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.
source code
Variables [hide private]
  GRACE2IMAGES = '#!/usr/bin/env python3\n\n####################...
  __package__ = 'lib.plotting'

Imports: ceil, sqrt, chmod, expanduser, S_IRWXU, S_IRGRP, S_IROTH, RelaxError, get_file_path, open_write_file


Function Details [hide private]

create_grace2images(dir=None)

source code 

Create the grace2images.py executable script.

Parameters:
  • dir (str) - The directory to place the script into.

script_grace2images(file=None)

source code 

Write a python "grace to PNG/EPS/SVG..." conversion script..

The makes a conversion script to image types as PNG/EPS/SVG. The conversion is looping over a directory list of *.agr files, and making function calls to xmgrace. Successful conversion of images depends on the compilation of xmgrace. The input is a list of image types which is wanted, f.ex: PNG EPS SVG. PNG is default.

Parameters:
  • file (file object) - The file object to write the data to.

write_xy_data(data, file=None, graph_type=None, norm_type='first', norm=None, autoscale=True)

source code 

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).

Parameters:
  • data (list of lists of lists of float) - The 4D structure of numerical data to graph (see docstring).
  • file (file object) - The file object to write the data to.
  • graph_type (str) - The graph type which can be one of xy, xydy, xydx, or xydxdy.
  • norm_type (str) - The point to normalise to 1. This can be 'first' or 'last'.
  • norm (None or list of bool) - The normalisation flag which if set to True will cause all graphs to be normalised to 1. The first dimension is the graph.
  • autoscale (bool) - 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.

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)

source code 

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).

Parameters:
  • file (file object) - The file object to write the data to.
  • paper_size (str) - The paper size, i.e. 'A4'. If set to None, this will default to letter size.
  • title (None or str) - The title of the graph.
  • subtitle (None or str) - The sub-title of the graph.
  • world (Nor or list of list of numbers) - 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.
  • view (None or list of float) - List of 4 coordinates defining the graph view port.
  • graph_num (int) - The total number of graphs.
  • sets (list of int) - The number of data sets in each graph.
  • set_names (None or list of list of str) - The names associated with each graph data set Gx.Sy. For example this can be a list of spin identification strings. The first dimension is the graph, the second is the set.
  • set_colours (None or list of list of int) - The colours for each graph data set Gx.Sy. The first dimension is the graph, the second is the set.
  • x_axis_type_zero (None or list of lists of bool) - The flags specifying if the X-axis should be placed at zero.
  • y_axis_type_zero (None or list of lists of bool) - The flags specifying if the Y-axis should be placed at zero.
  • symbols (None or list of list of int) - The symbol style for each graph data set Gx.Sy. The first dimension is the graph, the second is the set.
  • symbol_sizes (None or list of list of int) - The symbol size for each graph data set Gx.Sy. The first dimension is the graph, the second is the set.
  • symbol_fill (None or list of list of int) - The symbol file style for each graph data set Gx.Sy. The first dimension is the graph, the second is the set.
  • linestyle (None or list of list of int) - The line style for each graph data set Gx.Sy. The first dimension is the graph, the second is the set.
  • linetype (None or list of list of int) - The line type for each graph data set Gx.Sy. The first dimension is the graph, the second is the set.
  • linewidth (None or list of float) - The line width for all elements of each graph data set Gx.Sy. The first dimension is the graph, the second is the set.
  • data_type (None or list of list of str) - The axis data category (in the [X, Y] list format).
  • seq_type (None or list of list of str) - 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'.
  • tick_major_spacing (None or list of list of numbers) - The spacing between major ticks. This is in the [X, Y] list format whereby the first dimension corresponds to the graph number.
  • tick_minor_count (None or list of list of int) - 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.
  • axis_labels (None or list of list of str) - The labels for the axes (in the [X, Y] list format). The first dimension is the graph.
  • legend (list of bool) - If True, the legend will be visible. The first dimension is the graph.
  • legend_pos (None or list of list of float) - The position of the legend, e.g. [0.3, 0.8]. The first dimension is the graph.
  • legend_box_fill_pattern (int) - The legend box fill. If set to 0, it will become transparent.
  • legend_char_size (float) - The size of the legend box text.
  • norm (list of bool) - The normalisation flag which if set to True will cause all graphs to be normalised to 1. The first dimension is the graph.

Variables Details [hide private]

GRACE2IMAGES

Value:
'''#!/usr/bin/env python3

######################################################################\
#########
#                                                                     \
        #
# Copyright (C) 2013 Troels E. Linnet                                 \
        #
...