def plot_corr(param_1, param_2, title="", x_label="", y_label="", legend=[]):
"""
It creates a graph with all the time series of the list parameters.
:param title: Title of the graph.
:param x_label: X label of the graph.
:param y_label: Y label of the graph.
:param legend: Labels to show in the legend.
:param param_1: Parameter to correlate.
:param param_2: Parameter to correlate.
:return: The graph.
"""
slope, intercept, r_value, p_value, std_err = stats.linregress(param_1.values, param_2.values)
fig_correlation, axes = plt.subplots(nrows=1, ncols=1)
axes.plot(param_1.values, param_2.values, marker='.', linestyle="")
axes.plot(param_1.values, param_1.values * slope + intercept)
axes.set_title(title)
axes.set_xlabel(x_label)
axes.set_ylabel(y_label)
legend.append("$y = {:.2f}x+{:.2f}$ $r^2={:.2f}$".format(slope, intercept, r_value ** 2))
axes.legend(legend, loc='best')
return fig_correlation
评论列表
文章目录