ScatterPlotWithTwoHists

class lsst.analysis.tools.actions.plot.ScatterPlotWithTwoHists(*args, **kw)

Bases: PlotAction

Makes a scatter plot of the data with a marginal histogram for each axis.

Attributes Summary

addSummaryPlot

Add a summary plot to the figure? (bool, default True)

legendLocation

Legend position within main plot (str, default 'upper left')

magLabel

Label to use for the magnitudes used for SNR (str)

nBins

Number of bins on x axis (float, default 40.0)

plot2DHist

Plot a 2D histogram in dense areas of points on the scatter plot.Doesn't look great if plotting multiple datasets on top of each other.

plotTypes

Selection of types of objects to plot.

suffix_stat

Suffix for all binned statistic action inputs (str, default '')

suffix_x

Suffix for all x-axis action inputs (str, default '')

suffix_y

Suffix for all y-axis action inputs (str, default '')

xAxisLabel

Label to use for the x axis (str)

xLims

xlimits of the plot, if not specified determined from data (List, default None)

yAxisLabel

Label to use for the y axis (str)

yLims

ylimits of the plot, if not specified determined from data (List, default None)

Methods Summary

__call__(data, **kwargs)

Call self as a function.

getInputSchema()

Return the schema an AnalysisAction expects to be present in the arguments supplied to the __call__ method.

makePlot(data, skymap, plotInfo, **kwargs)

Makes a generic plot with a 2D histogram and collapsed histograms of each axis.

Attributes Documentation

addSummaryPlot

Add a summary plot to the figure? (bool, default True)

legendLocation

Legend position within main plot (str, default 'upper left')

magLabel

Label to use for the magnitudes used for SNR (str)

nBins

Number of bins on x axis (float, default 40.0)

plot2DHist

Plot a 2D histogram in dense areas of points on the scatter plot.Doesn’t look great if plotting multiple datasets on top of each other. (bool, default True)

plotTypes

Selection of types of objects to plot. Can take any combination of stars, galaxies, unknown, any (List)

suffix_stat

Suffix for all binned statistic action inputs (str, default '')

suffix_x

Suffix for all x-axis action inputs (str, default '')

suffix_y

Suffix for all y-axis action inputs (str, default '')

xAxisLabel

Label to use for the x axis (str)

xLims

xlimits of the plot, if not specified determined from data (List, default None)

yAxisLabel

Label to use for the y axis (str)

yLims

ylimits of the plot, if not specified determined from data (List, default None)

Methods Documentation

__call__(data: MutableMapping[str, ndarray[Any, dtype[ScalarType]] | Scalar | HealSparseMap | Tensor], **kwargs) Mapping[str, Figure] | Figure

Call self as a function.

getInputSchema() Tensor]]]

Return the schema an AnalysisAction expects to be present in the arguments supplied to the __call__ method.

Returns:
resultKeyedDataSchema

The schema this action requires to be present when calling this action, keys are unformatted.

makePlot(data: MutableMapping[str, ndarray[Any, dtype[ScalarType]] | Scalar | HealSparseMap | Tensor], skymap: BaseSkyMap, plotInfo: Mapping[str, str], **kwargs) Figure

Makes a generic plot with a 2D histogram and collapsed histograms of each axis.

Parameters:
dataKeyedData

The catalog to plot the points from.

skymaplsst.skymap.BaseSkyMap

The skymap that gives the patch locations

plotInfodict

A dictionary of information about the data being plotted with keys:

  • "run"

    The output run for the plots (str).

  • "skymap"

    The type of skymap used for the data (str).

  • "filter"

    The filter used for this data (str).

  • "tract"

    The tract that the data comes from (str).

Returns:
figmatplotlib.figure.Figure

The resulting figure.

Notes

Uses the axisLabels config options x and y and the axisAction config options xAction and yAction to plot a scatter plot of the values against each other. A histogram of the points collapsed onto each axis is also plotted. A summary panel showing the median of the y value in each patch is shown in the upper right corner of the resultant plot. The code uses the selectorActions to decide which points to plot and the statisticSelector actions to determine which points to use for the printed statistics.

If this function is being used within the pipetask framework that takes care of making sure that data has all the required elements but if you are running this as a standalone function then you will need to provide the following things in the input data.

  • If stars is in self.plotTypes:

    xStars, yStars, starsHighSNMask, starsLowSNMask and {band}_highSNStars_{name}, {band}_lowSNStars_{name} where name is median, sigma_Mad, count and approxMag.

  • If it is for galaxies/unknowns then replace stars in the above names with galaxies/unknowns.

  • If it is for any (which covers all the points) then it becomes, x, y, and any instead of stars for the other parameters given above.

  • In every case it is expected that data contains:

    lowSnThreshold, highSnThreshold and patch (if the summary plot is being plotted).

Examples

An example of the plot produced from this code is here:

../_images/scatterPlotExample.png

For a detailed example of how to make a plot from the command line please see the getting started guide.