code: def plot_density(
      ax,
      all_labels,
      to_plot,
      colors,
      bw,
      circular,
      figsize,
      length_plotters,
      rows,
      cols,
      textsize,
      labeller,
      hdi_prob,
      point_estimate,
      hdi_markers,
      outline,
      shade,
      n_data,
      data_labels,
      backend_kwargs,
      show,
  ):
      """Matplotlib densityplot."""
      if backend_kwargs is None:
          backend_kwargs = {}
  
      backend_kwargs = {
          **backend_kwarg_defaults(),
          **backend_kwargs,
      }
  
      if colors == "cycle":
          colors = [
              prop
              for _, prop in zip(
                  range(n_data),
                  cycle(
                      plt.rcParams["axes.prop_cycle"].by_key()["color"]
                  ),
              )
          ]
      elif isinstance(colors, str):
          colors = [colors for _ in range(n_data)]
  
      (
          figsize,
          _,
          titlesize,
          xt_labelsize,
          linewidth,
          markersize,
      ) = _scale_fig_size(figsize, textsize, rows, cols)
  
      backend_kwargs.setdefault("figsize", figsize)
      backend_kwargs.setdefault("squeeze", False)
      if ax is None:
          _, ax = create_axes_grid(
              length_plotters,
              rows,
              cols,
              backend_kwargs=backend_kwargs,
          )
  
      axis_map = dict(zip(all_labels, np.ravel(ax)))
  
      for m_idx, plotters in enumerate(to_plot):
          for var_name, selection, isel, values in plotters:
              label = labeller.make_label_vert(
                  var_name, selection, isel
              )
              _d_helper(
                  values.flatten(),
                  label,
                  colors[m_idx],
                  bw,
                  circular,
                  titlesize,
                  xt_labelsize,
                  linewidth,
                  markersize,
                  hdi_prob,
                  point_estimate,
                  hdi_markers,
                  outline,
                  shade,
                  axis_map[label],
              )
  
      if n_data > 1:
          for m_idx, label in enumerate(data_labels):
              np.ravel(ax).item(0).plot(
                  [],
                  label=label,
                  c=colors[m_idx],
                  markersize=markersize,
              )
          np.ravel(ax).item(0).legend(fontsize=xt_labelsize)
  
      if backend_show(show):
          plt.show()
  
      return ax
  
file_path: arviz/arviz/plots/backends/matplotlib/densityplot.py
imports: from itertools import cycle
  import matplotlib.pyplot
  import numpy
  from ....stats import hdi
  from ....stats.density_utils import get_bins, kde
  from ...plot_utils import _scale_fig_size, calculate_point_estimate
  from .None import backend_kwarg_defaults, backend_show, create_axes_grid
label_desc: Use image node_id 1 for calling a global function with example usage: plot_density(ax, all_labels, to_plot, colors, bw, circular, figsize, length_plotters, rows, cols, textsize, labeller, hdi_prob, point_estimate, hdi_markers, outline, shade, n_data, data_labels, backend_kwargs, show) and returns: ax