3 Created on Tue May 4 11:07:21 2021
8 import matplotlib.pyplot
as plt
9 import matplotlib.dates
as mdates
11 warnings.filterwarnings(
'error', category=RuntimeWarning)
14 fontSz=9, timeInterval=24, yMin=0, yMax=None, lineWidth=0.75,
15 showXTicks=True, showTitle=True, colorOvrd=None, lineStyle='-'):
17 ax.plot(tFcst, fcstResults, linewidth=lineWidth, linestyle=lineStyle, color=colorOvrd)
19 ax.plot(tFcst, fcstResults, linewidth=lineWidth, linestyle=lineStyle)
22 ax.set_xlim(tFcst[0], tFcst[-1])
23 ax.set_ylim(bottom=yMin)
26 ax.get_yaxis().get_major_formatter().set_scientific(
False)
29 ax.xaxis.set_major_locator(mdates.HourLocator(interval=timeInterval))
31 ax.xaxis.set_major_formatter(mdates.DateFormatter(
'%m-%d-%Hz'))
32 ax.xaxis.set_tick_params(rotation = 45)
33 for label
in ax.xaxis.get_majorticklabels():
34 label.set_horizontalalignment(
'right')
36 ax.set_xticklabels([])
37 ax.xaxis.grid(
True, which=
'major', linestyle=
':')
38 ax.yaxis.grid(
True, which=
'major', linestyle=
':')
39 plt.setp(ax.get_yticklabels(), fontsize=fontSz)
40 ax.set_ylabel(parameter+
' ('+units+
')', fontsize=fontSz)
41 if showTitle: ax.set_title(parameter, fontsize=fontSz)
45 nameThreshold='Storage Threshold', fontSz=9, timeInterval=24, yMin=0, yMax=None,
46 showXTicks=True, showTitle=True):
47 ax.plot(tFcst, riskTol*100,
'b--', linewidth=1, label=
'Risk Tolerance')
48 ax.plot(tFcst, riskFcst*100,
'r-', linewidth=1.5, label=
'Forecasted Risk')
49 ax.set_xlim(tFcst[0], tFcst[-1])
50 ax.set_ylim(bottom=0, top=yMax)
53 ax.xaxis.set_major_locator(mdates.HourLocator(interval=timeInterval))
55 ax.xaxis.set_major_formatter(mdates.DateFormatter(
'%m-%d-%Hz'))
56 ax.xaxis.set_tick_params(rotation = 45)
57 for label
in ax.xaxis.get_majorticklabels():
58 label.set_horizontalalignment(
'right')
60 ax.set_xticklabels([])
61 ax.xaxis.grid(
True, which=
'major', linestyle=
':')
62 ax.yaxis.grid(
True, which=
'major', linestyle=
':')
63 plt.setp(ax.get_xticklabels(), fontsize=fontSz)
64 plt.setp(ax.get_yticklabels(), fontsize=fontSz)
65 ax.set_ylabel(
'Risk (%)', fontsize=fontSz)
66 ax.set_xlabel(
'Date', fontsize=fontSz)
67 ax.legend(prop=dict(size=fontSz), loc=
'upper left')
68 if showTitle: ax.set_title(
'% of Ensemble Members > '+nameThreshold, fontsize=fontSz)