code: def _get_timeline_plot(info: _TimelineInfo) -> "Axes":
      _cm = {
          TrialState.COMPLETE.name: "tab:blue",
          TrialState.FAIL.name: "tab:red",
          TrialState.PRUNED.name: "tab:orange",
          _INFEASIBLE_KEY: "#CCCCCC",
          TrialState.RUNNING.name: "tab:green",
          TrialState.WAITING.name: "tab:gray",
      }
      # Set up the graph style.
      plt.style.use(
          "ggplot"
      )  # Use ggplot style sheet for similar outputs to plotly.
      fig, ax = plt.subplots()
      ax.set_title("Timeline Plot")
      ax.set_xlabel("Datetime")
      ax.set_ylabel("Trial")
  
      if len(info.bars) == 0:
          return ax
  
      ax.barh(
          y=[b.number for b in info.bars],
          width=[b.complete - b.start for b in info.bars],
          left=[b.start for b in info.bars],
          color=[_cm[_get_state_name(b)] for b in info.bars],
      )
  
      # There are 5 types of TrialState in total.
      # However, the legend depicts only types present in the arguments.
      legend_handles = []
      for state_name, color in _cm.items():
          if any(_get_state_name(b) == state_name for b in info.bars):
              legend_handles.append(
                  matplotlib.patches.Patch(
                      color=color, label=state_name
                  )
              )
      ax.legend(
          handles=legend_handles,
          loc="upper left",
          bbox_to_anchor=(1.05, 1.0),
      )
      fig.tight_layout()
  
      assert len(info.bars) > 0
      start_time = min([b.start for b in info.bars])
      complete_time = max([b.complete for b in info.bars])
      margin = (complete_time - start_time) * 0.05
  
      ax.set_xlim(
          right=complete_time + margin, left=start_time - margin
      )
      ax.yaxis.set_major_locator(
          matplotlib.ticker.MaxNLocator(integer=True)
      )
      ax.xaxis.set_major_formatter(
          matplotlib.dates.DateFormatter("%H:%M:%S")
      )
      plt.gcf().autofmt_xdate()
      return ax
  
file_path: optuna/optuna/visualization/matplotlib/_timeline.py
imports: from optuna._experimental import experimental_func
  from optuna.study import Study
  from optuna.trial import TrialState
  from optuna.visualization._timeline import _get_timeline_info
  from optuna.visualization._timeline import _TimelineBarInfo
  from optuna.visualization._timeline import _TimelineInfo
  from optuna.visualization.matplotlib._matplotlib_imports import _imports
label_desc: Use image node_id 3 for calling a global function with example usage: _get_timeline_plot(info) and returns: ax, ax