Package pylal :: Module plotutils
[hide private]
[frames] | no frames]

Module plotutils

source code

This module is intended to store generic, reusable, sub-classable plot classes to minimize formulaic copying and pasting.


Author: Nickolas Fotopoulos <nvf@gravity.phys.uwm.edu>

Classes [hide private]
  BasicPlot
A very default meta-class to almost any plot you might want to make.
  SimplePlot
Exactly what you get by calling pylab.plot(), but with the handy extras of the BasicPlot class.
  BarPlot
A simple vertical bar plot.
  VerticalBarHistogram
Histogram data sets with a common binning, then make a vertical bar plot.
  NumberVsBinBarPlot
Make a bar plot in which the width and placement of the bars are set by the given bins.
  CumulativeHistogramPlot
Cumulative histogram of foreground that also has a shaded region, determined by the mean and standard deviation of the background population coincidence statistics.
  ImagePlot
The equivalent of pylab.imshow(), but with the BasicPlot niceties and some defaults that are more in tune with what a scientist wants -- origin="lower", requiring x and y bins so that we can label axes correctly, and a colorbar.
  FillPlot
Given a list of vertices (passed by x-coords and y-coords), fill the regions (by default with successively darker gray shades).
  SixStripSeriesPlot
Given a time- or frequency-series, plot it across six horizontal axes, stacked on top of one another.
  ROCPlot
Plot the receiver operating characteristic (ROC) based on the foreground and background values from given techniques.
  QQPlot
Plot the global rank versus the self rank, like a Q-Q plot, i.e.
  SimpleMapPlot
Class to create a clickable map html page.
  Plot3D
Exactly what you get by calling pylab.plot(), but with the handy extras of the BasicPlot class.
  ScatterPlot
Exactly what you get from calling pylab.scatter(), but with the handy extras of the BasicPlot class.
  ColorbarScatterPlot
Exactly what you get from calling pylab.scatter() when you want a colorbar, but with the handy extras of the BasicPlot class.
  PlotSegmentsPlot
Horizontal bar segment plot.
  DQScatterPlot
A DQ-formatted scatter plot, with those triggers below some threshold on the colour axis get plotted tiny wee.
  LineHistogram
A simple line histogram plot.
  SkyPositionsPlot
A spherical projection plot.
  TestSimpleMapPlot
Functions [hide private]
 
float_to_latex(x, format="%.2g")
Convert a floating point number to a latex representation.
source code
 
default_colors()
An infinite iterator of some default colors.
source code
 
default_symbols()
An infinite iterator of some default symbols.
source code
 
determine_common_bin_limits(data_sets, default_min=0, default_max=0)
Given a some nested sequences (e.g.
source code
 
method_callable_once(f)
Decorator to make a method complain if called more than once.
source code
 
set_rcParams(params=_dq_params)
Update pylab plot parameters, defaulting to parameters for DQ-style trigger plots.
source code
 
display_name(columnName)
Format the string columnName (e.g.
source code
 
add_colorbar(ax, mappable=None, visible=True, log=False, clim=None, label=None, **kwargs)
Adds a figure colorbar to the given Axes object ax, based on the values found in the mappable object.
source code
 
parse_plot_config(cp, section)
Parser ConfigParser.ConfigParser section for plotting parameters.
source code
 
log_transform(lin_range)
Return the logarithmic ticks and labels corresponding to the input lin_range.
source code
 
time_axis_unit(duration)
Work out renormalisation for the time axis, makes the label more appropriate.
source code
 
set_time_ticks(ax)
Quick utility to set better formatting for ticks on a time axis.
source code
 
set_minor_ticks(ax, x=True, y=True)
Labels first minor tick in the case that there is only a single major tick label visible.
source code
Variables [hide private]
  _dq_params = {"text.usetex": True, "text.verticalalignment": "...
  plot3D_head = ...
  plot3D_body = ...
Function Details [hide private]

float_to_latex(x, format="%.2g")

source code 

Convert a floating point number to a latex representation. In particular, scientific notation is handled gracefully: e -> 10^

determine_common_bin_limits(data_sets, default_min=0, default_max=0)

source code 

Given a some nested sequences (e.g. list of lists), determine the largest and smallest values over the data sets and determine a common binning.

display_name(columnName)

source code 

Format the string columnName (e.g. xml table column) into latex format for
an axis label. Formats known acronyms, greek letters, units, subscripts, and
some miscellaneous entries.

Examples:

>>> display_name('snr')
'SNR'
>>> display_name('bank_chisq_dof')
'Bank $\chi^2$ DOF'
>>> display_name('hoft')
'$h(t)$'

Arguments:

  columnName : str
    string to format

add_colorbar(ax, mappable=None, visible=True, log=False, clim=None, label=None, **kwargs)

source code 

Adds a figure colorbar to the given Axes object ax, based on the values
found in the mappable object. If visible=True, returns the Colorbar object, 
otherwise, no return.

Arguments:

    ax : matplotlib.axes.AxesSubplot
        axes object beside which to draw colorbar

Keyword arguments:

    mappable : [ matplotlib.image.Image | matplotlib.contour.ContourSet... ]
        image object from which to map colorbar values
    visible : [ True | False]
        add colorbar to figure, or simply resposition ax as if to draw one
    log : [ True | False ]
        use logarithmic scale for colorbar
    clim : tuple
        (vmin, vmax) pair for limits of colorbar
    label : str
        label string for colorbar

All other keyword arguments will be passed to pylab.colorbar. Logarithmic
colorbars can be created by plotting log10 of the data and setting log=True.

parse_plot_config(cp, section)

source code 

Parser ConfigParser.ConfigParser section for plotting parameters. Returns
a dict that can be passed to any plotutils.plot_xxx function in **kwargs
form. Set ycolumn to 'hist' or 'rate' to generate those types of plots.

Arguments:

    cp : ConfigParser.ConfigParser
        INI file object from which to read
    section : str
        section name to read for options

Basic parseable options:

    xcolumn : str
        parameter to plot on x-axis    
    ycolumn : str
        parameter to plot on y-axis    
    zcolumn : str
        parameter to plot on z-axis    
    rank-by : str
        parameter by which to rank elements
    xlim : list
        [xmin, xmax] pair for x-axis limits
    ylim : list
        [ymin, ymax] pair for y-axis limits
    zlim : list
        [zmin, zmax] pair for z-axis limits
    clim : list
        [cmin, cmax] pair for colorbar limits
    logx : [ True | False ]
        plot x-axis in log scale
    logy : [ True | False ]
        plot y-axis in log scale
    logz : [ True | False ]
        plot z-axis in log scale

Trigger plot options:

    detchar-style : [ True | False ]
        use S6-style plotting: low snr triggers small with no edges
    detchar-style-theshold : float
        z-column threshold at below which to apply detchar-style

Trigger rate plot options:

    bins : str
        semi-colon-separated list of comma-separated bins for rate plot

Histogram options:

    cumulative : [ True | False ]
        plot cumulative counts in histogram
    rate : [ True | False ]
        plot histogram counts as rate
    num-bins : int
        number of bins for histogram
    fill : [ True | False ]
        plot solid colour underneath histogram curve
    color-bins : str
        semi-colon-separated list of comma-separated bins for colorbar
        histogram

Data plot options:

    zero-indicator : [ True | False ]
        draw vertical dashed red line at t=0

Other options:

    greyscale : [ True | False ]
        save plot in black-and-white
    bbox-inches : 'tight'
        save figure with tight bounding box around Axes
    calendar-time : [ True | False ]
        plot time axis with date and time instead of time from zero.

time_axis_unit(duration)

source code 

Work out renormalisation for the time axis, makes the label more
appropriate. Returns unit (in seconds) and string descriptor.

Example:

>>> time_axis_unit(100)
(1, 'seconds')

>>> time_axis_unit(604800)
(86400, 'days')

Arguments:

    duration : float
        plot duration to normalise


Variables Details [hide private]

_dq_params

Value:
{"text.usetex": True, "text.verticalalignment": "center", "lines.linew\
idth": 2, "xtick.labelsize": 16, "ytick.labelsize": 16, "axes.titlesiz\
e": 22, "axes.labelsize": 16, "axes.linewidth": 1, "grid.linewidth": 1\
, "legend.fontsize": 16, "legend.loc": "best", "figure.figsize": [12, \
6], "figure.dpi": 80, "image.origin": 'lower', "axes.grid": True, "axe\
s.axisbelow": False}

plot3D_head

Value:
"""
  <style type="text/css">
    .rotationViewer {
      position:relative;
      width:640px;
      height:378px;
      border-style:solid;
      border-width:1px;
...

plot3D_body

Value:
"""
<script type="text/javascript" src="PATHTOUIZE/Uize.js"></script>

<div class="main">
  <div id="page_rotationViewer" class="rotationViewer insetBorderColor\
"></div>
</div>

...