Miscellaneous

utilities.plotUtilities.effective_local_density(numPlot, X, Y, xerr, yerr, xmin=None, xmax=None, ymin=None, ymax=None, dx=1, dy=1, nx=None, ny=None)[source]

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

Generate an effective local density plot.

The idea is that, given a set of measurements for which we have values of the data points scatter in X and Y, rather than just plotting those values with error bars, we can instead try to compute the “likelihood” of having data points in a particular location.

Information

The “likelihood” is represented as an effective 2D density:

  • If we are located infinitely far away from the bulk of the points, then we expect the density to drop to 0.

  • On the other hand, if all the measurements are located at the same location with 0 error assigned to them, then we expect to have a density maximised as N/box size of a point.

This gives an idea of how clustered along a certain relation the points could be given their error bars.

But, error bars are only indicators of how “wrong” the measurement could be. They do not strictly show the lower and upper bounds of the measurement.

Error bars are sometimes represented as a 1 sigma width of a Gaussian distribution centered at that measurement location. Thus, we are assuming that this is the case here.

Warning

This is purely experimental.

Parameters
  • numPlot (list[3 int] or ndarray[3 int] or int or matplotlib GridSpec instance) –

    plot identifier. It can be

    • an int (format is XYZ with X the number of rows, Y the number of columns and Z the plot position)

    • a list with 3 similar numbers [X, Y, Z]

    • a matplotlib GridSpec instance

  • X (ndarray[int] or ndarray[float]) – X position of the data points

  • xerr (ndarray[int] or ndarray[float]) – X axis error on the data points

  • Y (ndarray[int] or ndarray[float]) – y position of the data points

  • yerr (ndarray[int] or ndarray[float]) – y axis error on the data points

  • dx (int or float) – (Optional) x axis step used to draw the grid. If nx is provided, this parameter is overriden.

  • dy (int or floats) – (Optional) y axis step used to draw the grid. If ny is provided, this parameters is overriden

  • nx (int) – (Optional) number of cells along the x axis. If None, dx is used instead to compute this value.

  • ny (int) – (Optional) number of cells along the y axis. If None, dy is used instead to compute this value.

  • xmin (int or float) – (Optional) minimum x axis value for the x axis of the plot. If None, data points values will be used as bound.

  • xmax (int or float) – (Optional) maximum x axis value for the x axis of the plot. If None, data points values will be used as bound.

  • ymin (int or float) – (Optional) minimum y axis value for the y axis of the plot. If None, data points values will be used as bound.

  • ymax (int or float) – (Optional) maximum y axis value for the y axis of the plot. If None, data points values will be used as bound.

Returns

matplotlib main axis

Raises
  • TypeError – if neither X, Y, xerr nor yerr is of type ndarray

  • ValueError – if either xmin, xmax, ymin or ymax is nan