pyp_graphics contains routines for working with graphics in PyPedal, such as
creating directed graphs from pedigrees using PyDot and visualizing relationship
matrices using Rick Muller's spy and pcolor routines
(http://aspn.activestate.com/ASPN/Cookbook/Python/).
The Python Imaging Library (http://www.pythonware.com/products/pil/),
matplotlib (http://matplotlib.sourceforge.net/), Graphviz (http://www.graphviz.org/),
and pydot (http://dkbza.org/pydot.html) are required by one or more routines in this
module. They ARE NOT distributed with PyPedal and must be installed by the end-user!
Note that the matplotlib functionality in PyPedal requires only the Agg backend, which
means that you do not have to install GTK/PyGTK or WxWidgets/PyWxWidgets just to use
PyPedal. Please consult the sites above for licensing and installation information.
- draw_pedigree(pedobj, gfilename='pedigree', gtitle='', gformat='jpg', gsize='f', gdot='1', gorient='p', gdirec='', gname=0, gfontsize=10, garrow=1, gtitloc='b', gtitjust='c') ⇒ integer [#]
-
draw_pedigree() uses the pydot bindings to the graphviz library -- if they
are available on your system -- to produce a directed graph of your pedigree
with paths of inheritance as edges and animals as nodes. If there is more than
one generation in the pedigree as determind by the "gen" attributes of the animals
in the pedigree, draw_pedigree() will use subgraphs to try and group animals in the
same generation together in the drawing.
- pedobj
-
A PyPedal pedigree object.
- gfilename
-
The name of the file to which the pedigree should be drawn
- gtitle
-
The title of the graph.
- gformat
-
The format in which the output file should be written (JPG|PNG|PS).
- gsize
-
The size of the graph: 'f': full-size, 'l': letter-sized page.
- gdot
-
Whether or not to write the dot code for the pedigree graph to a file (can produce large files).
- gorient
-
The orientation of the graph: 'p': portrait, 'l': landscape.
- gdirec
-
Direction of flow from parents to offspring: 'TB': top-bottom, 'LR': left-right, 'RL': right-left.
- gname
-
Flag indicating whether ID numbers (0) or names (1) should be used to label nodes.
- gfontsize
-
Integer indicating the typeface size to be used in labelling nodes.
- garrow
-
Flag indicating whether or not arrowheads should be drawn.
- gtitloc
-
Indicates if the title be drawn or above ('t') or below ('b') the graph.
- gtitjust
-
Indicates if the title should be center- ('c'), left- ('l'), or right-justified ('r').
- Returns:
-
A 1 for success and a 0 for failure.
- pcolor_matrix_pylab(A, fname='pcolor_matrix_matplotlib') ⇒ lists [#]
-
pcolor_matrix_pylab() implements a matlab-like 'pcolor' function to
display the large elements of a matrix in pseudocolor using the Python Imaging
Library.
- A
-
Input Numpy matrix (such as a numerator relationship matrix).
- fname
-
Output filename to which to dump the graphics (default 'tmp.png')
- do_outline
-
Whether or not to print an outline around the block (default 0)
- height
-
The height of the image (default 300)
- width
-
The width of the image (default 300)
- Returns:
-
A list of Animal() objects; a pedigree metadata object.
- plot_founders_by_year(pedobj, gfilename='founders_by_year', gtitle='Founders by Birthyear') ⇒ integer [#]
-
founders_by_year() uses matplotlib -- if available on your system -- to produce a
bar graph of the number (count) of founders in each birthyear.
- pedobj
-
A PyPedal pedigree object.
- gfilename
-
The name of the file to which the pedigree should be drawn
- gtitle
-
The title of the graph.
- Returns:
-
A 1 for success and a 0 for failure.
- plot_founders_pct_by_year(pedobj, gfilename='founders_pct_by_year', gtitle='Founders by Birthyear') ⇒ integer [#]
-
founders_pct_by_year() uses matplotlib -- if available on your system -- to produce a
line graph of the frequency (percentage) of founders in each birthyear.
- pedobj
-
A PyPedal pedigree object.
- gfilename
-
The name of the file to which the pedigree should be drawn
- gtitle
-
The title of the graph.
- Returns:
-
A 1 for success and a 0 for failure.
- plot_line_xy(xydict, gfilename='plot_line_xy', gtitle='Value by key', gxlabel='X', gylabel='Y', gformat='png') ⇒ integer [#]
-
plot_line_xy() uses matplotlib -- if available on your system -- to produce a
line graph of the values in a dictionary for each level of key.
- dictionary
-
A Python dictionary
- gfilename
-
The name of the file to which the figure should be written
- gtitle
-
The title of the graph.
- gxlabel
-
The label for the x-axis.
- gylabel
-
The label for the y-axis.
- Returns:
-
A 1 for success and a 0 for failure.
- rmuller_get_color(a, cmin, cmax) ⇒ integer [#]
-
rmuller_get_color() Converts a float value to one of a continuous range of colors
using recipe 9.10 from the Python Cookbook.
- a
-
Float value to convert to a color.
- cmin
-
Minimum value in array (?).
- cmax
-
Maximum value in array (?).
- Returns:
-
An RGB triplet.
- rmuller_pcolor_matrix_pil(A, fname='tmp.png', do_outline=0, height=300, width=300) ⇒ lists [#]
-
rmuller_pcolor_matrix_pil() implements a matlab-like 'pcolor' function to
display the large elements of a matrix in pseudocolor using the Python Imaging
Library.
- A
-
Input Numpy matrix (such as a numerator relationship matrix).
- fname
-
Output filename to which to dump the graphics (default 'tmp.png')
- do_outline
-
Whether or not to print an outline around the block (default 0)
- height
-
The height of the image (default 300)
- width
-
The width of the image (default 300)
- Returns:
-
A list of Animal() objects; a pedigree metadata object.
- rmuller_spy_matrix_pil(A, fname='tmp.png', cutoff=0.1, do_outline=0,
height=300, width=300) ⇒ lists [#]
-
rmuller_spy_matrix_pil() implements a matlab-like 'spy' function to display the
sparsity of a matrix using the Python Imaging Library.
- A
-
Input Numpy matrix (such as a numerator relationship matrix).
- fname
-
Output filename to which to dump the graphics (default 'tmp.png')
- cutoff
-
Threshold value for printing an element (default 0.1)
- do_outline
-
Whether or not to print an outline around the block (default 0)
- height
-
The height of the image (default 300)
- width
-
The width of the image (default 300)
- Returns:
-
A list of Animal() objects; a pedigree metadata object.
- spy_matrix_pylab(A, fname='spy_matrix_matplotlib') ⇒ lists [#]
-
spy_matrix_pylab() implements a matlab-like 'pcolor' function to
display the large elements of a matrix in pseudocolor using the Python Imaging
Library.
- A
-
Input Numpy matrix (such as a numerator relationship matrix).
- fname
-
Output filename to which to dump the graphics (default 'tmp.png')
- do_outline
-
Whether or not to print an outline around the block (default 0)
- height
-
The height of the image (default 300)
- width
-
The width of the image (default 300)
- Returns:
-
A list of Animal() objects; a pedigree metadata object.