code: def _get_figure_with_position(
      position: dict,
      report_normal: pd.DataFrame,
      label_data: pd.DataFrame,
      start_date=None,
      end_date=None,
  ) -> Iterable[go.Figure]:
      """Get average analysis figures
  
      :param position: position
      :param report_normal:
      :param label_data:
      :param start_date:
      :param end_date:
      :return:
      """
  
      cum_return_df = _get_cum_return_data_with_position(
          position, report_normal, label_data, start_date, end_date
      )
      cum_return_df = cum_return_df.set_index("date")
      # FIXME: support HIGH-FREQ
      cum_return_df.index = cum_return_df.index.strftime("%Y-%m-%d")
  
      # Create figures
      for _t_name in ["buy", "sell", "buy_minus_sell", "hold"]:
          sub_graph_data = [
              (
                  "cum_{}".format(_t_name),
                  dict(
                      row=1,
                      col=1,
                      graph_kwargs={
                          "mode": "lines+markers",
                          "xaxis": "x3",
                      },
                  ),
              ),
              (
                  "{}_weight".format(
                      _t_name.replace("minus", "plus")
                      if "minus" in _t_name
                      else _t_name
                  ),
                  dict(row=2, col=1),
              ),
              (
                  "{}_value".format(_t_name),
                  dict(
                      row=1,
                      col=2,
                      kind="HistogramGraph",
                      graph_kwargs={},
                  ),
              ),
          ]
  
          _default_xaxis = dict(
              showline=False, zeroline=True, tickangle=45
          )
          _default_yaxis = dict(
              zeroline=True, showline=True, showticklabels=True
          )
          sub_graph_layout = dict(
              xaxis1=dict(
                  **_default_xaxis,
                  type="category",
                  showticklabels=False,
              ),
              xaxis3=dict(**_default_xaxis, type="category"),
              xaxis2=_default_xaxis,
              yaxis1=dict(**_default_yaxis, title=_t_name),
              yaxis2=_default_yaxis,
              yaxis3=_default_yaxis,
          )
  
          mean_value = cum_return_df["{}_value".format(_t_name)].mean()
          layout = dict(
              height=500,
              title=f"{_t_name}(the red line in the histogram on the right represents the average)",
              shapes=[
                  {
                      "type": "line",
                      "xref": "x2",
                      "yref": "paper",
                      "x0": mean_value,
                      "y0": 0,
                      "x1": mean_value,
                      "y1": 1,
                      # NOTE: 'fillcolor': '#d3d3d3', 'opacity': 0.3,
                      "line": {"color": "red", "width": 1},
                  },
              ],
          )
  
          kind_map = dict(
              kind="ScatterGraph", kwargs=dict(mode="lines+markers")
          )
          specs = [
              [{"rowspan": 1}, {"rowspan": 2}],
              [{"rowspan": 1}, None],
          ]
          subplots_kwargs = dict(
              vertical_spacing=0.01,
              rows=2,
              cols=2,
              row_width=[1, 2],
              column_width=[3, 1],
              print_grid=False,
              specs=specs,
          )
          yield SubplotsGraph(
              cum_return_df,
              layout=layout,
              kind_map=kind_map,
              sub_graph_layout=sub_graph_layout,
              sub_graph_data=sub_graph_data,
              subplots_kwargs=subplots_kwargs,
          ).figure
  
file_path: qlib/qlib/contrib/report/analysis_position/cumulative_return.py
imports: import copy
  from typing import Iterable
  import pandas
  import plotly.graph_objs
  from ..graph import BaseGraph, SubplotsGraph
  from ..analysis_position.parse_position import get_position_data
label_desc: Use image node_id 2 for calling a global function with example usage: _get_figure_with_position(position, report_normal, label_data, start_date, end_date) without return types