class_docstr: All parameters computed for the plotnine tight layout engine
class_docstr_tok: ["All","parameters","computed","for","the","plotnine","tight","layout","engine"]
docstr: Modify TightParams to get a given aspect ratio
docstr_tok: ["Modify","TightParams","to","get","a","given","aspect","ratio"]
code: def to_aspect_ratio(
      self, facet: Facet, ratio: float, parts: WHSpaceParts
  ) -> TightParams:
      """
      Modify TightParams to get a given aspect ratio
      """
      current_ratio = (parts.h * parts.H) / (parts.w * parts.W)
      increase_aspect_ratio = ratio > current_ratio
      if increase_aspect_ratio:  # Taller panel
          return self._reduce_width(facet, ratio, parts)
      else:
          return self._reduce_height(facet, ratio, parts)
  
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 2 for calling the TightParams obj's underlying member method code with example usage: obj.to_aspect_ratio(facet, ratio, parts) and returns: self, self