density_scatter

Import in python using from mcutils.plot import density_scatter

mcutils.plot.density_scatter(x, y, xlog=False, ylog=False, max_dens_npoints=300, axes=None, diagonal=False, hue=None, colors=None, cmap='gist_heat', **kwargs)[source]

Produces a scatter plot color-coded by density

Parameters
  • x – (N, ) array with the x-values

  • y – (N, ) array with the y-values

  • xlog – if True, makes the x-axis logarithmic

  • ylog – if True, makes the x-axis logarithmic

  • max_dens_npoints – maximum number of points to use in the density calculation. Computation time on my laptop is roughly (max_dens_points / 600) seconds

  • axes – matplotlib Axes object, which will be used for the scatter plot (default: current axis)

  • diagonal – If True plots a diagonal straight line illustrating where both axes are equal

  • hue – (N, ) index array with a categorical variable indicating the hue

  • colors – seaborn color pallette or sequence of colors (default: matplotlib color cycle)

  • cmap – color-map to used if hue is not set

  • kwargs – keyword arguments passed on to plt.scatter. Particularly useful are adjusting the size (e.g. s=1) or the opacity (e.g. alpha=0.3)

Returns

scatter object