code: def _plot_with_density(
      data_dict,
      main_fig,
      title="",
      xtitle="",
      ytitle="",
      yrange=None,
      is_categorical=False,
      density_name="Distribution",
      showlegend=False,
  ):
      bar_fig = plot_density(
          data_dict,
          xtitle=xtitle,
          name=density_name,
          is_categorical=is_categorical,
          color=COLORS[1],
      )
      figure = _two_plot(
          main_fig,
          bar_fig,
          title=title,
          xtitle=xtitle,
          share_xaxis=is_categorical,
          showlegend=showlegend,
      )
      figure["layout"]["yaxis1"].update(title="Score")
      figure["layout"]["yaxis2"].update(title="Density")
      if not is_categorical:
          figure["layout"]["bargap"] = 0
          figure["layout"]["xaxis2"].update(bar_fig.layout.xaxis)
          figure.update_xaxes(matches="x")
      if yrange is not None:
          figure["layout"]["yaxis1"].update(range=yrange)
  
      return figure
  
imports: import plotly.graph_objs
  import numpy
  from plotly import subplots
  import matplotlib.pyplot
  from numbers import Number
  import logging
label_desc: Use image node_id 8 for calling a global function with example usage: _plot_with_density(data_dict, main_fig, title, xtitle, ytitle, yrange, is_categorical, density_name, showlegend) and returns: figure