def common_plotting_settings(plot, plot_def, xaxis_title, yaxis_title, legend="inside"):
    """Common settings for plots

    Args:
        plot: a pyplot plot object
        plot_def: a `PlotDef` that defines properties of the plot
        xaxis_title: label for x-axis
        yaxis_title: label for y-axis
        legend: where to put the legend; allowed values: None, "inside", "outside"
    """
    plot.set_xlabel(xaxis_title)
    plot.set_ylabel(yaxis_title)
    if plot_def.title:
        plot.set_title(plot_def.title)
    plot.grid(True)
    if legend == "outside":
        legend = plot.legend(loc='upper left', bbox_to_anchor=(1, 1))
        return legend
    elif legend == "inside":
        plot.legend()
    elif isinstance(legend, tuple) and legend[0] == "outside" and type(legend[1]) == float:
        legend = plot.legend(bbox_to_anchor=(1, legend[1]), loc=2) # , borderaxespad=0.)
        return legend