clevar.match_metrics.plot_helper module¶
- clevar.match_metrics.plot_helper.add_grid(ax, major_lw=0.5, minor_lw=0.1)[source]¶
Adds a grid to ax
- Parameters
ax (matplotlib.axes) – Ax to add plot
major_lw (float) – Line width of major axes
minor_lw (float) – Line width of minor axes
- clevar.match_metrics.plot_helper.add_panel_bin_label(axes, edges_lower, edges_higher, format_func=<function <lambda>>, prefix='')[source]¶
Adds label with bin range on the top of panel
- Parameters
axes (matplotlib.axes) – Axes with the panels
edges_lower (array) – Lower values of bins
edges_higher (array) – Higher values of bins
format_func (function) – Function to format the values of the bins
prefix (str) – Prefix to add to labels
- clevar.match_metrics.plot_helper.get_bin_label(edge_lower, edge_higher, format_func=<function <lambda>>, prefix='')[source]¶
Get label with bin range
- Parameters
edge_lower (float) – Lower values of bin
edge_higher (float) – Higher values of bin
format_func (function) – Function to format the values of the bins
prefix (str) – Prefix to add to labels
- Returns
Label of bin
- Return type
srt
- clevar.match_metrics.plot_helper.get_density_colors(x, y, xbins, ybins, ax_rotation=0, rotation_resolution=30, xscale='linear', yscale='linear')[source]¶
Get colors of point based on density
- Parameters
x (array) – Values for x coordinate
y (array) – Values for y coordinate
xbins (array, int) – Bins for x
ybins (array, int) – Bins for y
ax_rotation (float) – Angle (in degrees) for rotation of axis of binning. Overwrites use of xbins, ybins
rotation_resolution (int) – Number of bins to be used when ax_rotation!=0.
xscale (str) – Scale xaxis.
yscale (str) – Scale yaxis.
- Returns
Density value at location of each point
- Return type
ndarray
- clevar.match_metrics.plot_helper.nice_panel(axes, xlabel=None, ylabel=None, xscale='linear', yscale='linear')[source]¶
Add nice labels and ticks to panel plot
- Parameters
axes (array) – Axes with the panels
bins1 (array, int) – Bins for component 1
bins2 (array, int) – Bins for component 2
ax (matplotlib.axes) – Ax to add plot
xlabel (str) – Label of x axis.
ylabel (str) – Label of y axis.
xscale (str) – Scale xaxis.
yscale (str) – Scale yaxis.
- Returns
fig (matplotlib.figure.Figure) – matplotlib.figure.Figure object
axes (array) – Axes with the panels
- clevar.match_metrics.plot_helper.plot_healpix_map(healpix_map, nest=True, auto_lim=False, bad_val=None, ra_lim=None, dec_lim=None, fig=None, figsize=None, **kwargs)[source]¶
Plot healpix map.
- Parameters
healpix_map (numpy array) – Healpix map (must be 12*(2*n)**2 size).
nest (bool) – If ordering is nested
auto_lim (bool) – Set automatic limits for ra/dec, requires bad_val.
bad_val (float, None) – Values for pixels outside footprint.
ra_lim (None, list) – Min/max RA for plot.
dec_lim (None, list) – Min/max DEC for plot.
fig (matplotlib.figure.Figure, None) – Matplotlib figure object. If not provided a new one is created.
figsize (tuple) – Width, height in inches (float, float). Default value from hp.cartview.
**kwargs –
Extra arguments for hp.cartview:
xsize (int) : The size of the image. Default: 800
title (str) : The title of the plot. Default: None
min (float) : The minimum range value
max (float) : The maximum range value
remove_dip (bool) : If
True
, remove the dipole+monopoleremove_mono (bool) : If
True
, remove the monopolegal_cut (float, scalar) : Symmetric galactic cut for the dipole/monopole fit. Removes points in latitude range [-gal_cut, +gal_cut]
format (str) : The format of the scale label. Default: ‘%g’
cbar (bool) : Display the colorbar. Default: True
notext (bool) : If True, no text is printed around the map
norm ({‘hist’, ‘log’, None}) : Color normalization, hist= histogram equalized color mapping, log= logarithmic color mapping, default: None (linear color mapping)
cmap (a color map) : The colormap to use (see matplotlib.cm)
badcolor (str) : Color to use to plot bad values
bgcolor (str) : Color to use for background
margins (None or sequence) : Either None, or a sequence (left,bottom,right,top) giving the margins on left,bottom,right and top of the axes. Values are relative to figure (0-1). Default: None
- Returns
fig (matplotlib.pyplot.figure) – Figure of the plot.
ax (matplotlib.axes) – Ax to add plot
cb (matplotlib.pyplot.colorbar, None) – Colorbar
- clevar.match_metrics.plot_helper.plot_hist_line(hist_values, bins, ax, shape='steps', rotate=False, **kwargs)[source]¶
Plot recovey rate as lines. Can be in steps or continuous
- Parameters
hist_values (array) – Values of each bin in the histogram
bins (array, int) – Bins of histogram
ax (matplotlib.axes) – Ax to add plot
shape (str) – Shape of the line. Can be steps or line.
rotate (bool) – Invert x-y axes in plot
kwargs (parameters) – Additional parameters for plt.plot. It also includes the possibility of smoothening the line with n_increase, scheme arguments. See clevar.utils.smooth_line for details.
- clevar.match_metrics.plot_helper.plot_histograms(histogram, edges1, edges2, ax, shape='steps', plt_kwargs=None, lines_kwargs_list=None, add_legend=True, legend_format=<function <lambda>>, legend_kwargs=None)[source]¶
Plot recovery rate as lines, with each line binned by bins1 inside a bin of bins2.
- Parameters
histogram (array) – Histogram 2D with dimention (edges2, edges1).
edges1 (array) – Edges of histogram.
edges2 (array) – Edges of histogram.
ax (matplotlib.axes) – Ax to add plot
shape (str) – Shape of the lines. Can be steps or line.
plt_kwargs (dict, None) – Additional arguments for pylab.plot
lines_kwargs_list (list, None) – List of additional arguments for plotting each line (using pylab.plot). Must have same size as len(bins2)-1
add_legend (bool) – Add legend of bins
legend_format (function) – Function to format the values of the bins in legend
legend_kwargs (dict, None) – Additional arguments for pylab.legend
- Return type
ax