plot
Module¶
Module for making plots with matplotlib.
Written by Jesse Bloom.
Functions defined in this module¶
- PlotLogLvsNParams : plots log likelihood versus number of parameters.
- PlotYearVersusDistance : plots year separation versus distance
- PlotSiteLikelihoods : plots site likelihood comparison
-
plot.
PlotLogLvsNParams
(plotfile, data_d)¶ Plots log likelihood (y-axis) versus number of parameters (x-axis).
Requires matplotlib and pylab, and will raise an exception if not available.
CALLING VARIABLES:
plotfile is a string giving the name of the created plotfile. Should end in the extension
.pdf
.data_d specifies the data points to be plotted. Each data point has three pieces of information:
- The plotting_group (a string).
- The number of parameters (number plotted on x-axis).
- The log likelihood (number plotted on y-axis).
Points in the same plotting_group are plotted with the same symbol and have the same legend entry.
data_d specifies these points as follows. data_d is a dictionary that is keyed by the plotting_group string. The entries for each string is a list of one or more 2-tuples. Each 2-tuple specifies a data point for that plotting_group as (log_likelihood, nparams).
Overall, data_d must specify at least two data points (although they can both be from the same plotting group if yo would like).
-
plot.
PlotSiteLikelihoods
(sites, classifications, classificationtypes, xvalues, xlabel, ylabel, plotfile, symmetrize_axis=True, title='', alpha=1)¶ Plots comparison of site likelihoods.
Requires
matplotlib
/pylab
, will raise an exception if not available.This function plots a comparison of the log likelihoods at a set of sites.
Typically you will have computed the difference in the log likelihoods for each site over two different models. You may then have classified the sites into one or more categories. This function plots points showing the differences in log likelihoods for all sites in each classification.
The each set of data is plotted using a box plots.
All strings (xlabel, ylabel, classificationtypes, title) use
LaTex
formatting.CALLING VARIABLES:
- sites is a list of integer sites (should all be unique)
- classifications is a dictionary that is keyed by all integers in sites. The values should be some set of (relatively few) strings that define the site classification. Don’t make too many classifications, as a separate row is plotted for each.
- classificationtypes is a list of the classifications (the unique values in classifications) in the order they should be plotted from bottom to top on the y-axis.
- xvalues is a dictionary keyed by all integers in sites, with the value being the number plotted on the x-axis. Typically this would be the difference in log likelihoods between model 1 and model 2.
- xlabel is the string label for the x-axis. This might be something like LogL for model 1 - LogL for model 2.
- ylabel is the string label for the y-axis.
- plotfile is the name of the created plot. Must have the extension
.pdf
. - symmetrize_axis is a Boolean switch specifying if we make the x-axis range equal at both ends (i.e. goes from -10 to 10). Is True by default.
- title is an optional string above the plot. Is empty (‘’) by default.
Uses
LaTex
formatting. - alpha is the transparency of the plotted points. An alpha of 1 means no transparency, and alpha less than one means transparent. Is 1 by default.
-
plot.
PlotYearVersusDistance
(plotfile, years, distances, xlabel='Year of isolation', ylabel='Distance', title=None)¶ Makes scatter plot of year versus distance.
Requires
matplotlib
/pylab
; will raise an exception if not available.- plotfile : name of created PDF plot.
- years : list of years, plotted on x-axis.
- distances : list of distances, as same length as years and with corresponding entries. Plotted on y-axis.
- xlabel : label for the x-axis, uses LaTex formatting.
- ylabel : label for the y-axis, uses LaTex formatting.
- title : if set to a non-empty value, is a string title placed above plot.