Skip to content

Instantly share code, notes, and snippets.

@toniesteves
Created March 12, 2020 20:09
Show Gist options
  • Select an option

  • Save toniesteves/0038cf76a3a6335682f5c3777b5bbc61 to your computer and use it in GitHub Desktop.

Select an option

Save toniesteves/0038cf76a3a6335682f5c3777b5bbc61 to your computer and use it in GitHub Desktop.
def plot(self,run_results,with_alarm = True, positions = None):
"""
Plot the results of given by the run
Parameters
----------
run_results : dict
results given by the 'run' method
with_alarm : bool
(default = True) If True, alarms are plotted.
positions : dict
positions from image
Returns
----------
list
list of the plots
"""
x = range(self.data.size)
K = run_results.keys()
SUB = str.maketrans("0123456789", "₀₁₂₃₄₅₆₇₈₉")
data_labels = np.arange(0, 3880, 1.0).tolist()
ts_fig, = plt.plot(x,self.data,color=air_force_blue)
fig = [ts_fig]
if 'thresholds' in K:
th = run_results['thresholds']
th_fig, = plt.plot(x,th,color=deep_saffron,lw=2,ls='dashed')
fig.append(th_fig)
if with_alarm and ('alarms' in K):
alarm = run_results['alarms']
al_fig = plt.scatter(alarm,self.data[alarm],color='red')
fig.append(al_fig)
if positions.any():
for (idx, val) in zip(alarm, self.data[alarm]):
plt.text(idx+.3,val.item()+.3,"X"+positions[idx].replace("_",",").translate(SUB) , fontsize=19)
plt.xlim((0,self.data.size))
return fig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment