class_docstr: All parameters computed for the plotnine tight layout engine
class_docstr_tok: ["All","parameters","computed","for","the","plotnine","tight","layout","engine"]
docstr: Reduce the width of axes to get the aspect ratio
docstr_tok: ["Reduce","the","width","of","axes","to","get","the","aspect","ratio"]
code: def _reduce_width(
      self, facet: Facet, ratio: float, parts: WHSpaceParts
  ) -> TightParams:
      """
      Reduce the width of axes to get the aspect ratio
      """
      params = deepcopy(self)
      spaces = params.spaces
      grid = params.grid
  
      # New width w.r.t figure width
      w1 = (parts.h * parts.H) / (ratio * parts.W)
  
      # Half of the total horizontal reduction w.r.t figure width
      dw = (parts.w - w1) * facet.ncol / 2
  
      # Reduce width
      grid.left += dw
      grid.right -= dw
      grid.wspace = parts.sw / w1
  
      # Add more horizontal margin
      spaces.l.plot_margin += dw
      spaces.r.plot_margin += dw
      return params
  
file_path: plotnine/plotnine/_mpl/_plotnine_tight_layout.py
imports: from __future__ import annotations
  import typing
  from copy import deepcopy
  from dataclasses import dataclass
  from matplotlib.offsetbox import AnchoredOffsetbox
  from ._plot_side_space import LRTBSpaces, WHSpaceParts, calculate_panel_spacing
label_desc: Use image node_id 4 for calling the TightParams obj's underlying member method code with example usage: obj._reduce_width(facet, ratio, parts) and returns: params