contur.plot package
Submodules
contur.plot.color_config module
contur.plot.contur_plot module
main module of heatmap plotting functions
- class contur.plot.contur_plot.AxesHolder(xAxis, xAxisMesh, xLabel, xLog, yAxis, yAxisMesh, yLabel, yLog, title)[source]
Bases:
object
Data structure to keep things legible in the code, holds the Axes scoped from the map file and information about how we visualise it. Just used for book keeping
- class contur.plot.contur_plot.ConturPlotBase(conturDepot, outPath, plotTitle='', savePlotFile=False, omittedPools='', iLevel=3, iOrder=3, iSigma=0.75, clLevel=0, style='DRAFT', showcls=False, simplecls=False, show_secondary=False, show_hl=False, interactive_mode=False, min_cls=0.68)[source]
Bases:
Depot
ConturPlotBase extends the depot class to dress things nicely for plotting, it also contains all the steering functions the default plotting macro needs
Todo
a config file based setup to stop the command line argument bloat in the plotting macro
- add_external_functions(ExternalFunctions)[source]
Switch to provide the external exclusion function files to the PlotBase instance
- add_external_grids(ExternalGrids)[source]
Switch to provide the external exclusion grid files to the PlotBase instance
- build_axes()[source]
Function to build the axis dictionaries used for plotting, parameter space points are otherwise stored unordered
- Built variables:
mapAxis (
dict
)plotAxis (
dict
)
@TODO should seperate the data structures from the plotting.
- build_axes_from_grid(xarg, yarg, logX=False, logY=False, xlabel=None, ylabel=None)[source]
Function to build the axes out of the underlying map, creates an AxesHolder instance to store the info and pass nicely to the plotting engine
Todo
Refactor how we store the grids in general, should just reuse the initial scanning functions to build the space OTF
- build_grid(xarg, yarg)[source]
Build the grid in the style mpl needs to make it easy to plot, converts the unordered dictionary of paramPoints into a structured numpy array
Todo
revive ND capabilities, might need a total overhaul of how we do this
- build_grid_from_data(stat_type, xarg, yarg)[source]
Build a plotting grid from the expected and secondary statistics Assumes the keys for the parameters are the same for all points and grabs them from first point :param xarg: the x-axis variable name :param yarg: the y-axis variable name
- build_grid_from_functions(xarg, yarg)[source]
Builds the grid to pointwise evaluate external function on :param xarg: the x-axis variable name :param yarg: the y-axis variable name
- build_grid_from_grid(xarg, yarg)[source]
Build a plotting grid from the supplied external grids Assumes the keys for the parameters are the same for all points and grabs them from first point :param xarg: the x-axis variable name :param yarg: the y-axis variable name
- build_special_grid(xarg, yarg)[source]
build_special_grid allows us to build an empty grid from the sampled points dictionary, this is used for adding custom functions to evaluate on the grid. For example see the log-read snippets prepared for the BL paper
- check_args(xarg, yarg)[source]
Function to call to check the requested arguments of what to plot are compatible with what is in the map
- dump_color_palette_tex()[source]
Function to dump a .tex file containing a LaTeX legend for the dominant pools plots.
- dump_plot_objects()[source]
Small function to dump a pickle of the plot objects if requested, this is to allow any mpl image manipulation without using the contur package at all
- get_parameters(variables_only=False)[source]
Returns a list of parameters in the db. Returns only independent variables if variables_only=True
- property map_axis
Dictionary of the sampled values in each axis
type (
dict
) – key – Parameter name (string
), value – (numpy.ndarray
)
- parse_slice(slice_str)[source]
Function to parse the slice string from the command line to a dictionary.
- property plot_axis
Dictionary of the offset midpoints in each axis, for colormesh purposes
type (
dict
) – key – Parameter name (string
), value – (numpy.ndarray
)
- property points
The master list of
LikelihoodPoint
instances added to the Depot instancetype (
list
[LikelihoodPoint
])
- set_output_path(outputpath)[source]
Convenience switch to set the output path name for the PlotBase instance
- slice_grid(slice_str)[source]
Filter the list of points to those which meet the 2D slice parameters
- contur.plot.contur_plot.color_tint(col, tintfrac)[source]
Return a colour as rgb tuple, with a fraction tintfrac of white mixed in (or pass a negative tintfrac to mix with black, giving a shade rather than tint
- class contur.plot.contur_plot.conturPlot(saveAxes=False, plotTitle='', iLevel=3, iOrder=3, iSigma=0.75, style='DRAFT', showcls=False, simplecls=False, interactive_mode=False, primary_stat='SMBG')[source]
Bases:
object
conturPlot is the engine that interacts with the matplotlib.pyplot plotting library
- add_external_data_grids(external_data_grids)[source]
Add the alternative data grids, this is a workaround for now .. todo:: Revisit the implementation of smoothing using scipy’s interpolator here
- add_grid(numpyGrid, label, dest, axHolder)[source]
Main access method to give the plot all the attributes it needs in a numpy format that feeds directly into mpl
- interpolate_grid(level=3, sigma=0.75, order=3)[source]
Use scipy’s interpolators to create smoothed & zoomed versions of the grid and axes
- plot_hybrid()[source]
Build the default contur output for combined limit, a hybrid plot showing both a colormesh of the underlying exclusion and the derived 1 and 2 sigma confidence intervals from this space Makes the file combinedHybrid.pdf.
- plot_levels()[source]
Make an individual levels plot, currently just used for compatibility to show the individual pools Makes the file combinedLevels.pdf .. todo:: Derive these from the main hybrid plot
- plot_mesh(make_cbar)[source]
Make an individual colormesh plot, currently just used for compatibility to show the individual pools .. todo:: Derive these from the main hybrid plot Makes the file combinedMesh.pdf
contur.plot.label_maker module
This file is to allow some closer interaction with the labels put on plots, this is just to keep the conturPlot methods cleaner until a good UI for placing labels is dreamt up. In the meantime, if you want to label curves on plots, you will have to write methods here and modify the addLimits function in contur_plot.py to use them.
pass the axes instance you want to dress with a label to a function to do that
#TODO Look at an optional second legend
contur.plot.axis_labels module
Define some default axis labels
contur.plot.html_utils module
- contur.plot.html_utils.plot_render_html(file, obsname, analysis, vis=False, size='300')[source]
Constructs an html snippet linking a rivet/contur plot. Writes in to the open file
arguments: :param file: an opened file to write to :param obsname: the name of the histogram (last part of the yoda path) :param analysis: the analysis the histogram belongs to. :type analysis:
contur.data.data_objects.analysis
- contur.plot.html_utils.selectHistogramsForPlotting(histograms, pool_exclusions, CLs, print_only, include_none)[source]
concatenate the histograms dict into a list of python scripts that will be executed based on analysis matching and a CLs cut-off
returns pyScripts = dict of scripts and output directories matchedPools, matchedAnalyses
- contur.plot.html_utils.writeAlistHTML(dir, ana_dict)[source]
write index.html file corresponding to a particular analyses and predictions in the cwd
- contur.plot.html_utils.writeAnaHTML(analysis, excl, anaDir, histoList, prediction=None)[source]
write index.html file corresponding to a particular analysis, showing the .png of histograms