Python matplotlib.pyplot.xlim() Examples
The following are 30
code examples of matplotlib.pyplot.xlim().
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
matplotlib.pyplot
, or try the search function
.
Example #1
Source File: utils.py From pruning_yolov3 with GNU General Public License v3.0 | 8 votes |
def plot_wh_methods(): # from utils.utils import *; plot_wh_methods() # Compares the two methods for width-height anchor multiplication # https://github.com/ultralytics/yolov3/issues/168 x = np.arange(-4.0, 4.0, .1) ya = np.exp(x) yb = torch.sigmoid(torch.from_numpy(x)).numpy() * 2 fig = plt.figure(figsize=(6, 3), dpi=150) plt.plot(x, ya, '.-', label='yolo method') plt.plot(x, yb ** 2, '.-', label='^2 power method') plt.plot(x, yb ** 2.5, '.-', label='^2.5 power method') plt.xlim(left=-4, right=4) plt.ylim(bottom=0, top=6) plt.xlabel('input') plt.ylabel('output') plt.legend() fig.tight_layout() fig.savefig('comparison.png', dpi=200)
Example #2
Source File: dataset.py From neural-combinatorial-optimization-rl-tensorflow with MIT License | 8 votes |
def visualize_2D_trip(self, trip): plt.figure(figsize=(30,30)) rcParams.update({'font.size': 22}) # Plot cities plt.scatter(trip[:,0], trip[:,1], s=200) # Plot tour tour=np.array(list(range(len(trip))) + [0]) X = trip[tour, 0] Y = trip[tour, 1] plt.plot(X, Y,"--", markersize=100) # Annotate cities with order labels = range(len(trip)) for i, (x, y) in zip(labels,(zip(X,Y))): plt.annotate(i,xy=(x, y)) plt.xlim(0,100) plt.ylim(0,100) plt.show() # Heatmap of permutations (x=cities; y=steps)
Example #3
Source File: 1logistic_regression.py From Fundamentals-of-Machine-Learning-with-scikit-learn with MIT License | 7 votes |
def show_classification_areas(X, Y, lr): x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5 y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5 xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.02), np.arange(y_min, y_max, 0.02)) Z = lr.predict(np.c_[xx.ravel(), yy.ravel()]) Z = Z.reshape(xx.shape) plt.figure(1, figsize=(30, 25)) plt.pcolormesh(xx, yy, Z, cmap=plt.cm.Pastel1) # Plot also the training points plt.scatter(X[:, 0], X[:, 1], c=np.abs(Y - 1), edgecolors='k', cmap=plt.cm.coolwarm) plt.xlabel('X') plt.ylabel('Y') plt.xlim(xx.min(), xx.max()) plt.ylim(yy.min(), yy.max()) plt.xticks(()) plt.yticks(()) plt.show()
Example #4
Source File: model.py From fake-news-detection with MIT License | 7 votes |
def print_roc(self, y_true, y_scores, filename): ''' Prints the ROC for this model. ''' fpr, tpr, thresholds = metrics.roc_curve(y_true, y_scores) plt.figure() plt.plot(fpr, tpr, color='darkorange', label='ROC curve (area = %0.2f)' % self.roc_auc) plt.plot([0, 1], [0, 1], color='navy', linestyle='--') plt.xlim([0.0, 1.0]) plt.ylim([0.0, 1.05]) plt.xlabel('False Positive Rate') plt.ylabel('True Positive Rate') plt.title('Receiver operating characteristic') plt.legend(loc="lower right") plt.savefig(filename) plt.close()
Example #5
Source File: __init__.py From EDeN with MIT License | 7 votes |
def plot_roc_curve(y_true, y_score, size=None): """plot_roc_curve.""" false_positive_rate, true_positive_rate, thresholds = roc_curve( y_true, y_score) if size is not None: plt.figure(figsize=(size, size)) plt.axis('equal') plt.plot(false_positive_rate, true_positive_rate, lw=2, color='navy') plt.plot([0, 1], [0, 1], color='gray', lw=1, linestyle='--') plt.xlabel('False positive rate') plt.ylabel('True positive rate') plt.ylim([-0.05, 1.05]) plt.xlim([-0.05, 1.05]) plt.grid() plt.title('Receiver operating characteristic AUC={0:0.2f}'.format( roc_auc_score(y_true, y_score)))
Example #6
Source File: dataset.py From neural-combinatorial-optimization-rl-tensorflow with MIT License | 7 votes |
def visualize_2D_trip(self,trip,tw_open,tw_close): plt.figure(figsize=(30,30)) rcParams.update({'font.size': 22}) # Plot cities colors = ['red'] # Depot is first city for i in range(len(tw_open)-1): colors.append('blue') plt.scatter(trip[:,0], trip[:,1], color=colors, s=200) # Plot tour tour=np.array(list(range(len(trip))) + [0]) X = trip[tour, 0] Y = trip[tour, 1] plt.plot(X, Y,"--", markersize=100) # Annotate cities with TW tw_open = np.rint(tw_open) tw_close = np.rint(tw_close) time_window = np.concatenate((tw_open,tw_close),axis=1) for tw, (x, y) in zip(time_window,(zip(X,Y))): plt.annotate(tw,xy=(x, y)) plt.xlim(0,60) plt.ylim(0,60) plt.show() # Heatmap of permutations (x=cities; y=steps)
Example #7
Source File: plot_threshold_vs_success_trans.py From pointnet-registration-framework with MIT License | 7 votes |
def make_plot(files, labels): plt.figure() for file_idx in range(len(files)): rot_err, trans_err = read_csv(files[file_idx]) success_dict = count_success(trans_err) x_range = success_dict.keys() x_range.sort() success = [] for i in x_range: success.append(success_dict[i]) success = np.array(success)/total_cases plt.plot(x_range, success, linewidth=3, label=labels[file_idx]) # plt.scatter(x_range, success, s=50) plt.ylabel('Success Ratio', fontsize=40) plt.xlabel('Threshold for Translation Error', fontsize=40) plt.tick_params(labelsize=40, width=3, length=10) plt.grid(True) plt.ylim(0,1.005) plt.yticks(np.arange(0,1.2,0.2)) plt.xticks(np.arange(0,2.1,0.2)) plt.xlim(0,2) plt.legend(fontsize=30, loc=4)
Example #8
Source File: display.py From radiometric_normalization with Apache License 2.0 | 6 votes |
def plot_pixels(file_name, candidate_data_single_band, reference_data_single_band, limits=None, fit_line=None): logging.info('Display: Creating pixel plot - {}'.format(file_name)) fig = plt.figure() plt.hexbin( candidate_data_single_band, reference_data_single_band, mincnt=1) if not limits: min_value = 0 _, ymax = plt.gca().get_ylim() _, xmax = plt.gca().get_xlim() max_value = max([ymax, xmax]) limits = [min_value, max_value] plt.plot(limits, limits, 'k-') if fit_line: start = limits[0] * fit_line.gain + fit_line.offset end = limits[1] * fit_line.gain + fit_line.offset plt.plot(limits, [start, end], 'g-') plt.xlim(limits) plt.ylim(limits) plt.xlabel('Candidate DNs') plt.ylabel('Reference DNs') fig.savefig(file_name, bbox_inches='tight') plt.close(fig)
Example #9
Source File: score.py From EvalNE with MIT License | 6 votes |
def _plot(self, results, x, y, x_label, y_label, curve, filename): r""" Contains the actual plot functionality. """ plt.plot(x, y) plt.xlabel(x_label) plt.ylabel(y_label) plt.ylim([0.0, 1.0]) plt.xlim([0.0, 1.0]) if results == 'test': plt.title('{} test set {} curve'.format(self.method, curve)) else: plt.title('{} train set {} curve'.format(self.method, curve)) if filename is not None: plt.savefig(filename + '_' + curve + '.pdf') plt.close() else: plt.show()
Example #10
Source File: test_filter.py From sprocket with MIT License | 6 votes |
def test_filter(self): fs = 8000 f0 = 440 sin = np.array([np.sin(2.0 * np.pi * f0 * n / fs) for n in range(fs * 1)]) noise = np.random.rand(len(sin)) - 0.5 wav = sin + noise lpfed = low_pass_filter(wav, 500, n_taps=255, fs=fs) hpfed = high_pass_filter(wav, 1000, n_taps=255, fs=fs) lpfed_2d = low_pass_filter(np.vstack([wav, noise]).T, 500, fs=fs) hpfed_2d = high_pass_filter(np.vstack([wav, noise]).T, 1000, fs=fs) if saveflag: plt.figure() plt.plot(lpfed, label='lpf') plt.plot(hpfed, label='hpf') plt.legend() plt.xlim(0, 100) plt.savefig('filter.png')
Example #11
Source File: classification.py From Kaggler with MIT License | 6 votes |
def plot_roc_curve(y, p): fpr, tpr, _ = roc_curve(y, p) plt.plot(fpr, tpr) plt.plot([0, 1], [0, 1], color='navy', linestyle='--') plt.xlim([0.0, 1.0]) plt.ylim([0.0, 1.05]) plt.xlabel('False Positive Rate') plt.ylabel('True Positive Rate')
Example #12
Source File: pixel.py From yatsm with MIT License | 6 votes |
def plot_DOY(dates, y, mpl_cmap): """ Create a DOY plot Args: dates (iterable): sequence of datetime y (np.ndarray): variable to plot mpl_cmap (colormap): matplotlib colormap """ doy = np.array([d.timetuple().tm_yday for d in dates]) year = np.array([d.year for d in dates]) sp = plt.scatter(doy, y, c=year, cmap=mpl_cmap, marker='o', edgecolors='none', s=35) plt.colorbar(sp) months = mpl.dates.MonthLocator() # every month months_fmrt = mpl.dates.DateFormatter('%b') plt.tick_params(axis='x', which='minor', direction='in', pad=-10) plt.axes().xaxis.set_minor_locator(months) plt.axes().xaxis.set_minor_formatter(months_fmrt) plt.xlim(1, 366) plt.xlabel('Day of Year')
Example #13
Source File: logger.py From MobileNetV3-pytorch with MIT License | 6 votes |
def plot_progress_errk(self, claimed_acc=None, title='MobileNetV3', k=1): tr_str = 'train_error{}'.format(k) val_str = 'val_error{}'.format(k) plt.figure(figsize=(9, 8), dpi=300) plt.plot(self.data[tr_str], label='Training error') plt.plot(self.data[val_str], label='Validation error') if claimed_acc is not None: plt.plot((0, len(self.data[tr_str])), (1 - claimed_acc, 1 - claimed_acc), 'k--', label='Claimed validation error ({:.2f}%)'.format(100. * (1 - claimed_acc))) plt.plot((0, len(self.data[tr_str])), (np.min(self.data[val_str]), np.min(self.data[val_str])), 'r--', label='Best validation error ({:.2f}%)'.format(100. * np.min(self.data[val_str]))) plt.title('Top-{} error for {}'.format(k, title)) plt.xlabel('Epoch') plt.ylabel('Error') plt.legend() plt.xlim(0, len(self.data[tr_str]) + 1) plt.savefig(os.path.join(self.log_path, 'top{}-{}.png'.format(k, self.local_rank)))
Example #14
Source File: plot_util.py From DeepLearningSmells with Apache License 2.0 | 6 votes |
def save_precision_recall_curve(eval_labels, pred_labels, average_precision, smell, config, out_folder, dim, method): fig = plt.figure() precision, recall, _ = precision_recall_curve(eval_labels, pred_labels) step_kwargs = ({'step': 'post'} if 'step' in signature(plt.fill_between).parameters else {}) plt.step(recall, precision, color='b', alpha=0.2, where='post') plt.fill_between(recall, precision, alpha=0.2, color='b', **step_kwargs) plt.xlabel('Recall') plt.ylabel('Precision') plt.ylim([0.0, 1.05]) plt.xlim([0.0, 1.0]) if isinstance(config, cfg.CNN_config): title_str = smell + " (" + method + " - " + dim + ") - L=" + str(config.layers) + ", E=" + str(config.epochs) + ", F=" + str(config.filters) + \ ", K=" + str(config.kernel) + ", PW=" + str(config.pooling_window) + ", AP={0:0.2f}".format(average_precision) # plt.title(title_str) # plt.show() file_name = get_plot_file_name(smell, config, out_folder, dim, method, "_prc_") fig.savefig(file_name)
Example #15
Source File: demos.py From bayesian_bootstrap with MIT License | 6 votes |
def plot_mean_bootstrap_exponential_readme(): X = np.random.exponential(7, 4) classical_samples = [np.mean(resample(X)) for _ in range(10000)] posterior_samples = mean(X, 10000) l, r = highest_density_interval(posterior_samples) classical_l, classical_r = highest_density_interval(classical_samples) plt.subplot(2, 1, 1) plt.title('Bayesian Bootstrap of mean') sns.distplot(posterior_samples, label='Bayesian Bootstrap Samples') plt.plot([l, r], [0, 0], linewidth=5.0, marker='o', label='95% HDI') plt.xlim(-1, 18) plt.legend() plt.subplot(2, 1, 2) plt.title('Classical Bootstrap of mean') sns.distplot(classical_samples, label='Classical Bootstrap Samples') plt.plot([classical_l, classical_r], [0, 0], linewidth=5.0, marker='o', label='95% HDI') plt.xlim(-1, 18) plt.legend() plt.savefig('readme_exponential.png', bbox_inches='tight')
Example #16
Source File: visualize.py From adversarial-policies with MIT License | 5 votes |
def comparative_densities( env, victim_id, n_components, covariance, cutoff_point=None, savefile=None, **kwargs ): """PDF of different opponents density distribution. For unspecified parameters, see get_full_directory. :param cutoff_point: (float): left x-limit. :param savefile: (None or str) path to save figure to. :param kwargs: (dict) passed through to sns.kdeplot.""" df = load_metadata(env, victim_id, n_components, covariance) fig = plt.figure(figsize=(10, 7)) grped = df.groupby("opponent_id") for name, grp in grped: # clean up random_none to just random name = name.replace("_none", "") avg_log_proba = np.mean(grp["log_proba"]) sns.kdeplot(grp["log_proba"], label=f"{name}: {round(avg_log_proba, 2)}", **kwargs) xmin, xmax = plt.xlim() xmin = max(xmin, cutoff_point) plt.xlim((xmin, xmax)) plt.suptitle(f"{env} Densities, Victim Zoo {victim_id}: Trained on Zoo 1", y=0.95) plt.title("Avg Log Proba* in Legend") if savefile is not None: fig.savefig(f"{savefile}.pdf")
Example #17
Source File: data.py From miccai-2016-surgical-activity-rec with Apache License 2.0 | 5 votes |
def visualize_predictions(prediction_seqs, label_seqs, num_classes, fig_width=6.5, fig_height_per_seq=0.5): """ Visualize predictions vs. ground truth. Args: prediction_seqs: A list of int NumPy arrays, each with shape `[duration, 1]`. label_seqs: A list of int NumPy arrays, each with shape `[duration, 1]`. num_classes: An integer. fig_width: A float. Figure width (inches). fig_height_per_seq: A float. Figure height per sequence (inches). Returns: A tuple of the created figure, axes. """ num_seqs = len(label_seqs) max_seq_length = max([seq.shape[0] for seq in label_seqs]) figsize = (fig_width, num_seqs*fig_height_per_seq) fig, axes = plt.subplots(nrows=num_seqs, ncols=1, sharex=True, figsize=figsize) for pred_seq, label_seq, ax in zip(prediction_seqs, label_seqs, axes): plt.sca(ax) plot_label_seq(label_seq, num_classes, 1) plot_label_seq(pred_seq, num_classes, -1) ax.get_xaxis().set_visible(False) ax.get_yaxis().set_visible(False) plt.xlim(0, max_seq_length) plt.ylim(-2.75, 2.75) plt.tight_layout() return fig, axes
Example #18
Source File: probs.py From tensorflow_end2end_speech_recognition with MIT License | 5 votes |
def plot_probs_framewise(probs, save_path, input_name): """Plot posteriors of frame-wise classifiers. Args: probs: posteriors of each class save_path: path to save graph """ # plot probs save_path = os.path.join(save_path, '{0:04d}'.format(input_name) + '.png') times = np.arange(len(probs)) * 0.01 plt.clf() # plt.figure(figsize=(10, 10)) plt.subplot(211) # plt.plot(times, probs[:, 0], label='garbage') plt.plot(times, probs[:, 1], label='laughter') plt.plot(times, probs[:, 2], label='filler') # plt.plot(probs[3][0:10], label='blank') plt.title('Probs: ' + save_path) plt.ylabel('Probability', fontsize=12) plt.xlim([0, times[-1]]) plt.ylim([0, 1]) plt.legend(loc='best') plt.grid(True) plt.tight_layout() # plot smoothed probs # plot waveform wav_path = '/n/sd8/inaguma/dataset/SVC/wav/S' + \ '{0:04d}'.format(input_name) + '.wav' sampling_rate, waveform = scipy.io.wavfile.read(wav_path) sampling_interval = 1.0 / sampling_rate waveform = waveform / 32768.0 # normalize times = np.arange(len(waveform)) * sampling_interval plt.subplot(212) plt.plot(times, waveform, color='grey') plt.xlabel('Time[sec]', fontsize=12) plt.ylabel('Amplitude', fontsize=12) plt.savefig(save_path) # plt.show()
Example #19
Source File: squad_evaluation.py From FARM with Apache License 2.0 | 5 votes |
def plot_pr_curve(precisions, recalls, out_image, title): plt.step(recalls, precisions, color='b', alpha=0.2, where='post') plt.fill_between(recalls, precisions, step='post', alpha=0.2, color='b') plt.xlabel('Recall') plt.ylabel('Precision') plt.xlim([0.0, 1.05]) plt.ylim([0.0, 1.05]) plt.title(title) plt.savefig(out_image) plt.clf()
Example #20
Source File: plot_util.py From DeepLearningSmells with Apache License 2.0 | 5 votes |
def save_roc_curve(fpr, tpr, roc_auc, smell, config, out_folder, dim): fig = plt.figure() lw = 2 plt.plot(fpr, tpr, color='darkorange', lw=lw, label='ROC curve (area = %0.2f)' % roc_auc) plt.plot([0, 1], [0, 1], color='green', lw=lw, linestyle='--') plt.xlim([0.0, 1.0]) plt.ylim([0.0, 1.05]) plt.xlabel('False Positive Rate') plt.ylabel('True Positive Rate') #plt.title('Receiver operating characteristic') plt.legend(loc="lower right") # plt.show() file_name = get_plot_file_name(smell, config, out_folder, dim, "_roc_") fig.savefig(file_name)
Example #21
Source File: linear_regression.py From PRML with MIT License | 5 votes |
def plotData(X, y): plt.scatter(X, y, c='red', marker='o', label="Training data") plt.xlabel("Population of city in 10,000s") plt.ylabel("Profit in $10,000s") plt.xlim(4, 24) plt.ylim(-5, 25)
Example #22
Source File: plot_hillslope_morphology.py From LSDMappingTools with MIT License | 5 votes |
def JoyPlot(HillslopeData,Column,XLabel,Colour,Outfile,BinMin,BinSpacing,BinMax): CreateFigure(AspectRatio=0.5,FigSizeFormat="small") Ax = plt.subplot(111) Basins = np.sort(HillslopeData.BasinID.unique()) for Basin in range(0,NoBasins): #Get hillslopes for basin BasinHillslopeData = HillslopeData[HillslopeData.BasinID == Basins[Basin]] #create the PDF freq, BinEdges = np.histogram(BasinHillslopeData[Column],bins=np.arange(BinMin,BinMax+BinSpacing,BinSpacing)) BinMidpoints = BinEdges+BinSpacing*0.5 freq_norm = freq.astype(np.float)/float(np.max(freq)) #plot, offset by Basin # plt.plot(BinMidpoints[:-1],freq_norm-Basin,'k-',linewidth=1) plt.fill_between(BinMidpoints[:-1],freq_norm-Basin,-Basin,color=Colour) if np.abs(BinMin) < np.abs(BinMax): plt.xlim(BinMin,BinMax) else: plt.xlim(BinMax,BinMin) BinSpacing *= -1 plt.xlabel(XLabel) plt.text(-BinSpacing,0,"North-West",rotation=90,verticalalignment='top') plt.text(-BinSpacing,-(NoBasins-1),"South-East",rotation=90,verticalalignment='bottom') #only display bottom axis Ax.spines['right'].set_visible(False) Ax.spines['top'].set_visible(False) Ax.spines['left'].set_visible(False) Ax.yaxis.set_visible(False) plt.tight_layout(rect=[0.02, 0.02, 0.98, 0.98]) plt.savefig(PlotDirectory+Outfile, dpi=300) plt.clf()
Example #23
Source File: k_means_clustering.py From FunUtils with MIT License | 5 votes |
def plot(kmeans, data): reduced_data = PCA(n_components=2).fit_transform(data) kmeans.fit(reduced_data) # Step size of the mesh. Decrease to increase the quality of the VQ. h = .01 # point in the mesh [x_min, x_max]x[y_min, y_max]. # Plot the decision boundary. For that, we will assign a color to each x_min, x_max = reduced_data[:, 0].min() - 1, reduced_data[:, 0].max() + 1 y_min, y_max = reduced_data[:, 1].min() - 1, reduced_data[:, 1].max() + 1 xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h)) # Obtain labels for each point in mesh. Use last trained model. Z = kmeans.predict(np.c_[xx.ravel(), yy.ravel()]) # Put the result into a color plot Z = Z.reshape(xx.shape) plt.figure(1) plt.clf() plt.imshow(Z, interpolation='nearest', extent=(xx.min(), xx.max(), yy.min(), yy.max()), cmap=plt.cm.Paired, aspect='auto', origin='lower') plt.plot(reduced_data[:, 0], reduced_data[:, 1], 'k.', markersize=2) # Plot the centroids as a white X centroids = kmeans.cluster_centers_ plt.scatter(centroids[:, 0], centroids[:, 1], marker='x', s=169, linewidths=3, color='w', zorder=10) plt.title('K-means clustering on the digits dataset (PCA-reduced data)\n' 'Centroids are marked with white cross') plt.xlim(x_min, x_max) plt.ylim(y_min, y_max) plt.xticks(()) plt.yticks(()) plt.show() # Loading and preparing the data
Example #24
Source File: benchmark.py From burnman with GNU General Public License v2.0 | 5 votes |
def check_vinet(): """ Recreates Dewaele et al., 2006, Figure 1, fitting a Vinet EOS to Fe data """ plt.close() # make a test mineral test_mineral = burnman.Mineral() test_mineral.params = {'name': 'test', 'V_0': 6.75e-6, 'K_0': 163.4e9, 'Kprime_0': 5.38, } test_mineral.set_method('vinet') pressure = np.linspace(17.7e9, 300.e9, 20) volume = np.empty_like(pressure) # calculate its static properties for i in range(len(pressure)): volume[i] = vinet.volume(pressure[i], test_mineral.params) # compare with figure 1 plt.plot(pressure / 1.e9, volume / 6.02e-7) fig1 = mpimg.imread('../../burnman/data/input_figures/Dewaele.png') plt.imshow(fig1, extent=[0., 300., 6.8, 11.8], aspect='auto') plt.plot(pressure / 1.e9, volume / 6.02e-7, marker='o', color='r', linestyle='', label='Vinet Fit') plt.legend(loc='lower left') plt.xlim(0., 300.) plt.ylim(6.8, 11.8) plt.ylabel("Volume (Angstroms^3/atom") plt.xlabel("Pressure (GPa)") plt.title("Comparing with Figure 1 of Dewaele et al., (2006)") plt.show()
Example #25
Source File: test_ms.py From sprocket with MIT License | 5 votes |
def test_MSstatistics(self): ms = MS() datalist = [] for i in range(1, 4): T = 200 * i data = low_pass_filter(np.random.rand(T * dim).reshape(T, dim), 50, fs=200, n_taps=63) datalist.append(data) msstats = ms.estimate(datalist) data = np.random.rand(500 * dim).reshape(500, dim) data_lpf = low_pass_filter(data, 50, fs=200, n_taps=63) data_ms = ms.logpowerspec(data) data_lpf_ms = ms.logpowerspec(data_lpf) odata = ms.postfilter(data, msstats, msstats, startdim=0) odata_lpf = ms.postfilter(data_lpf, msstats, msstats, startdim=0) assert data.shape[0] == odata.shape[0] if saveflag: # plot sequence plt.figure() plt.plot(data[:, 0], label='data') plt.plot(data_lpf[:, 0], label='data_lpf') plt.plot(odata[:, 0], label='odata') plt.plot(odata_lpf[:, 0], label='odata_lpf') plt.xlim(0, 100) plt.legend() plt.savefig('ms_seq.png') # plot MS plt.figure() plt.plot(msstats[:, 0], label='msstats') plt.plot(data_ms[:, 0], label='data') plt.plot(data_lpf_ms[:, 0], label='data_lpf') plt.plot(ms.logpowerspec(odata)[:, 0], label='mspf data') plt.plot(ms.logpowerspec(odata_lpf)[:, 0], label='mspf data_lpf') plt.xlim(0, msstats.shape[0] // 2 + 1) plt.legend() plt.savefig('ms.png')
Example #26
Source File: display.py From radiometric_normalization with Apache License 2.0 | 5 votes |
def plot_histograms(file_name, candidate_data_multiple_bands, reference_data_multiple_bands=None, # Default is for Blue-Green-Red-NIR: colour_order=['b', 'g', 'r', 'y'], x_limits=None, y_limits=None): logging.info('Display: Creating histogram plot - {}'.format(file_name)) fig = plt.figure() plt.hold(True) for colour, c_band in zip(colour_order, candidate_data_multiple_bands): c_bh, c_bins = numpy.histogram(c_band, bins=256) plt.plot(c_bins[:-1], c_bh, color=colour, linestyle='-', linewidth=2) if reference_data_multiple_bands: for colour, r_band in zip(colour_order, reference_data_multiple_bands): r_bh, r_bins = numpy.histogram(r_band, bins=256) plt.plot( r_bins[:-1], r_bh, color=colour, linestyle='--', linewidth=2) plt.xlabel('DN') plt.ylabel('Number of pixels') if x_limits: plt.xlim(x_limits) if y_limits: plt.ylim(y_limits) fig.savefig(file_name, bbox_inches='tight') plt.close(fig)
Example #27
Source File: evaluate.py From ssai-cnn with MIT License | 5 votes |
def draw_pre_rec_curve(pre_rec, breakeven_pt): plt.clf() plt.plot(pre_rec[:, 0], pre_rec[:, 1]) plt.plot(breakeven_pt[0], breakeven_pt[1], 'x', label='breakeven recall: %f' % (breakeven_pt[1])) plt.ylabel('recall') plt.xlabel('precision') plt.ylim([0.0, 1.1]) plt.xlim([0.0, 1.1]) plt.legend(loc='lower left') plt.grid(linestyle='--')
Example #28
Source File: evaluate_single.py From ssai-cnn with MIT License | 5 votes |
def draw_pre_rec_curve(pre_rec, breakeven_pt): plt.clf() plt.plot(pre_rec[:, 0], pre_rec[:, 1]) plt.plot(breakeven_pt[0], breakeven_pt[1], 'x', label='breakeven recall: %f' % (breakeven_pt[1])) plt.ylabel('recall') plt.xlabel('precision') plt.ylim([0.0, 1.1]) plt.xlim([0.0, 1.1]) plt.legend(loc='lower left') plt.grid(linestyle='--')
Example #29
Source File: logger.py From MobileNetV3-pytorch with MIT License | 5 votes |
def plot_progress_loss(self, title='MobileNetV3'): plt.figure(figsize=(9, 8), dpi=300) plt.plot(self.data['train_loss'], label='Training') plt.plot(self.data['val_loss'], label='Validation') plt.title(title) plt.xlabel('Epoch') plt.ylabel('Loss') plt.legend() plt.xlim(0, len(self.data['train_loss']) + 1) plt.savefig(os.path.join(self.log_path, 'loss-{}.png'.format(self.local_rank)))
Example #30
Source File: plot.py From sumo-rl with MIT License | 5 votes |
def plot_df(df, color, xaxis, yaxis, init_time=0, ma=1, acc=False, label=''): df[yaxis] = pd.to_numeric(df[yaxis], errors='coerce') # convert NaN string to NaN value mean = df.groupby(xaxis).mean()[yaxis] std = df.groupby(xaxis).std()[yaxis] if ma > 1: mean = moving_average(mean, ma) std = moving_average(std, ma) x = df.groupby(xaxis)[xaxis].mean().keys().values plt.plot(x, mean, label=label, color=color, linestyle=next(dashes_styles)) plt.fill_between(x, mean + std, mean - std, alpha=0.25, color=color, rasterized=True) #plt.ylim([0,200]) #plt.xlim([40000, 70000])