def samples_dict_plot(
    samples_variable, plot_args=[], plot_kwargs={}, extra_lines=[],
    text="As an example, we now plot the posterior samples"
):
    """Return a string containing the function to generate a plot

    Parameters
    ----------
    samples_variable: str
        name of the SamplesDict class
    plot_args: list, optional
        arguments for the `.plot()` method
    plot_kwargs: dict, optional
        kwargs for the `.plot()` method.
    extra_lines: list, optional
        additional lines to add to the end of the string
    text: str, optional
        Markdown text explaining the plot
    """
    args = ", ".join(plot_args)
    kwargs = ", ".join([f"{key}={item}" for key, item in plot_kwargs.items()])
    string = "fig = {}.plot({})\n".format(
        samples_variable, "%s, %s" % (args, kwargs) if len(args) else kwargs
    )
    string += "\n".join(extra_lines)
    if text is not None:
        return [text, string]
    return [string]