<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _set_with_height(self, fig, opts):
 """ Set the width and height of a Matplotlib figure """

        h = 5
        if "height" in opts:
            h = opts["height"]
        w = 12
        if "width" in opts:
            w = opts["width"]
        try:
            fig.figure.set_size_inches((w, h))
            return fig
        except Exception:
            try:
                fig.fig.set_size_inches((w, h))
                return fig
            except Exception as e:
                self.err(e, self._set_with_height,
                         "Can not set figure width and height from chart object")