Python pylab.axvline() Examples
The following are 7
code examples of pylab.axvline().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pylab
, or try the search function
.
Example #1
Source File: segmenter.py From msaf with MIT License | 6 votes |
def pick_peaks(nc, L=16): """Obtain peaks from a novelty curve using an adaptive threshold.""" offset = nc.mean() / 20. nc = filters.gaussian_filter1d(nc, sigma=4) # Smooth out nc th = filters.median_filter(nc, size=L) + offset #th = filters.gaussian_filter(nc, sigma=L/2., mode="nearest") + offset peaks = [] for i in range(1, nc.shape[0] - 1): # is it a peak? if nc[i - 1] < nc[i] and nc[i] > nc[i + 1]: # is it above the threshold? if nc[i] > th[i]: peaks.append(i) #plt.plot(nc) #plt.plot(th) #for peak in peaks: #plt.axvline(peak) #plt.show() return peaks
Example #2
Source File: View.py From Deep-Spying with Apache License 2.0 | 6 votes |
def plot_signal_and_label(self, title, timestamp, signal, label_timestamp, label): if not self.to_save and not self.to_show: return pylab.figure() pylab.plot(timestamp, signal, color='m', label='signal') for i in range(0, len(label_timestamp)): pylab.axvline(label_timestamp[i], color="k", label="{}: key {}".format(i, label[i]), ls='dashed') pylab.legend() pylab.title(title) pylab.xlabel('Time') pylab.ylabel('Amplitude')
Example #3
Source File: View.py From Deep-Spying with Apache License 2.0 | 6 votes |
def plot_sensor_data_and_segment(self, title, timestamp, x, y, z, segment, label): if not self.to_save and not self.to_show: return self.big_figure() pylab.plot(timestamp, x, color='r', label='x') pylab.plot(timestamp, y, color='g', label='y') pylab.plot(timestamp, z, color='b', label='z') for i in range(0, len(segment)): pylab.axvline(segment[i][0], color="c", ls='dashed') pylab.axvline(segment[i][1], color="k", label="{}: key {}".format(i, label[i]), ls='dashed') pylab.axvline(segment[i][2], color="m", ls='dashed') pylab.legend() pylab.title(title) pylab.xlabel('Time') pylab.ylabel('Amplitude')
Example #4
Source File: bandstructure.py From pyiron with BSD 3-Clause "New" or "Revised" License | 5 votes |
def plot(self): import pylab as plt q_ticks_int = [self.q_dist[i] for i in self.q_ticks] q_ticks_label = self.q_labels for i, q in enumerate(q_ticks_label): if q in self.translate_to_pylab: q_ticks_label[i] = self.translate_to_pylab[q] plt.plot(self.q_dist, self.ew_list) plt.xticks(q_ticks_int, q_ticks_label) for x in q_ticks_int: plt.axvline(x, color="black") return plt
Example #5
Source File: analyser.py From spotpy with MIT License | 5 votes |
def plot_objectivefunction(results,evaluation,limit=None,sort=True, fig_name = 'objective_function.png'): """Example Plot as seen in the SPOTPY Documentation""" import matplotlib.pyplot as plt likes=calc_like(results,evaluation,spotpy.objectivefunctions.rmse) data=likes #Calc confidence Interval mean = np.average(data) # evaluate sample variance by setting delta degrees of freedom (ddof) to # 1. The degree used in calculations is N - ddof stddev = np.std(data, ddof=1) from scipy.stats import t # Get the endpoints of the range that contains 95% of the distribution t_bounds = t.interval(0.999, len(data) - 1) # sum mean to the confidence interval ci = [mean + critval * stddev / np.sqrt(len(data)) for critval in t_bounds] value="Mean: %f" % mean print(value) value="Confidence Interval 95%%: %f, %f" % (ci[0], ci[1]) print(value) threshold=ci[1] happend=None bestlike=[data[0]] for like in data: if like<bestlike[-1]: bestlike.append(like) if bestlike[-1]<threshold and not happend: thresholdpos=len(bestlike) happend=True else: bestlike.append(bestlike[-1]) if limit: plt.plot(bestlike,'k-')#[0:limit]) plt.axvline(x=thresholdpos,color='r') plt.plot(likes,'b-') #plt.ylim(ymin=-1,ymax=1.39) else: plt.plot(bestlike) plt.savefig(fig_name)
Example #6
Source File: View.py From Deep-Spying with Apache License 2.0 | 5 votes |
def plot_sensor_data_and_label(self, title, timestamp, x, y, z, label_timestamp, label=None): if not self.to_save and not self.to_show: return self.big_figure() pylab.plot(timestamp, x, color='r', label='x') pylab.plot(timestamp, y, color='g', label='y') pylab.plot(timestamp, z, color='b', label='z') for i in range(0, len(label_timestamp)): if label is not None: if i != 0: pylab.axvline(label_timestamp[i], color="k", ls='dashed') else: pylab.axvline(label_timestamp[i], color="k", label="keystroke", ls='dashed') else: pylab.axvline(label_timestamp[i], color="k", ls='dashed') pylab.legend() pylab.title(title) pylab.xlabel('Time') pylab.ylabel('Amplitude') if label: pylab.xticks(label_timestamp, label)
Example #7
Source File: segmenter.py From msaf with MIT License | 4 votes |
def processFlat(self): """Main process. Returns ------- est_idxs : np.array(N) Estimated indeces the segment boundaries in frames. est_labels : np.array(N-1) Estimated labels for the segments. """ # Preprocess to obtain features F = self._preprocess() # Normalize F = msaf.utils.normalize(F, norm_type=self.config["bound_norm_feats"]) # Make sure that the M_gaussian is even if self.config["M_gaussian"] % 2 == 1: self.config["M_gaussian"] += 1 # Median filter F = median_filter(F, M=self.config["m_median"]) #plt.imshow(F.T, interpolation="nearest", aspect="auto"); plt.show() # Self similarity matrix S = compute_ssm(F) # Compute gaussian kernel G = compute_gaussian_krnl(self.config["M_gaussian"]) #plt.imshow(S, interpolation="nearest", aspect="auto"); plt.show() # Compute the novelty curve nc = compute_nc(S, G) # Find peaks in the novelty curve est_idxs = pick_peaks(nc, L=self.config["L_peaks"]) # Add first and last frames est_idxs = np.concatenate(([0], est_idxs, [F.shape[0] - 1])) # Empty labels est_labels = np.ones(len(est_idxs) - 1) * -1 # Post process estimations est_idxs, est_labels = self._postprocess(est_idxs, est_labels) return est_idxs, est_labels # plt.figure(1) # plt.plot(nc); # [plt.axvline(p, color="m") for p in est_bounds] # [plt.axvline(b, color="g") for b in ann_bounds] # plt.figure(2) # plt.imshow(S, interpolation="nearest", aspect="auto") # [plt.axvline(b, color="g") for b in ann_bounds] # plt.show()