<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def saveplot(fig, *name_args, close=True, **name_kwargs):
 """Save matplotlib figure. You need to provide :data:`stem` as a positional or keyword argument (see :func:`out_name`). Args: fig (:class:`matplotlib.figure.Figure`):
 matplotlib figure. close (bool):
 whether to close the figure. name_args: positional arguments passed on to :func:`out_name`. name_kwargs: keyword arguments passed on to :func:`out_name`. """

    oname = out_name(*name_args, **name_kwargs)
    fig.savefig('{}.{}'.format(oname, conf.plot.format),
                format=conf.plot.format, bbox_inches='tight')
    if close:
        plt.close(fig)