Plot lines with upper/lower bounds
- plot_utils.plot_with_error_bounds(x, y, upper_bound, lower_bound, fig=None, ax=None, figsize=None, dpi=100, line_color=[0.4, 0.4, 0.4], shade_color=[0.7, 0.7, 0.7], shade_alpha=0.5, linewidth=2.0, legend_loc='best', line_label='Data', shade_label='$\\mathregular{\\pm}$STD', logx=False, logy=False, grid_on=True)[source]
Plot a graph with one line and its upper and lower bounds, with areas between bounds shaded. The effect is similar to this illustration below:
y ^ ... _____________________ | ... .......... | | | . ______ . | --- Mean value | | ... / \ .. | ... Error bounds | | ... ___/ \ ... |_____________________| | . / ... \ ........ | . __/ ... .... \________ . | / .... ... \ . | / .... ..... \_ | ... .......... -|---------------------------------------> x
- Parameters:
x (list, numpy.ndarray, or pandas.Series) – X data points to be plotted as a line.
y (list, numpy.ndarray, or pandas.Series) – Y data points to be plotted as a line.
fig (matplotlib.figure.Figure or
None
) – Figure object. If None, a new figure will be created.ax (matplotlib.axes._subplots.AxesSubplot or
None
) – Axes object. If None, a new axes will be created.figsize ((float, float)) – Figure size in inches, as a tuple of two numbers. The figure size of
fig
(if notNone
) will override this parameter.dpi (float) – Figure resolution. The dpi of
fig
(if notNone
) will override this parameter.upper_bound (list, numpy.ndarray, or pandas.Series) – Upper bound of the Y values.
lower_bound (list, numpy.ndarray, or pandas.Series) – Lower bound of the Y values.
line_color (str, list, or tuple) – Color of the line.
shade_color (str, list, or tuple) – Color of the underlying shades.
shade_alpha (float) – Opacity of the shades.
linewidth (float) – Width of the line.
legend_loc (int, str) – Location of the legend, to be passed directly to
plt.legend()
.line_label (str) – Label of the line, to be used in the legend.
shade_label (str) – Label of the shades, to be used in the legend.
logx (bool) – Whether or not to show the X axis in log scale.
logy (bool) – Whether or not to show the Y axis in log scale.
grid_on (bool) – Whether or not to show grids on the plot.
- Returns:
fig (matplotlib.figure.Figure) – The figure object being created or being passed into this function.
ax (matplotlib.axes._subplots.AxesSubplot) – The axes object being created or being passed into this function.