Python pylab.subplot() Examples
The following are 30
code examples of pylab.subplot().
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
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: test_turbo_seti.py From turbo_seti with MIT License | 7 votes |
def plot_hits(filename_fil, filename_dat): """ Plot the hits in a .dat file. """ table = find_event.read_dat(filename_dat) print(table) plt.figure(figsize=(10, 8)) N_hit = len(table) if N_hit > 10: print("Warning: More than 10 hits found. Only plotting first 10") N_hit = 10 for ii in range(N_hit): plt.subplot(N_hit, 1, ii+1) plot_event.plot_hit(filename_fil, filename_dat, ii) plt.tight_layout() plt.savefig(filename_dat.replace('.dat', '.png')) plt.show()
Example #2
Source File: plot.py From TOPFARM with GNU Affero General Public License v3.0 | 7 votes |
def plot_wt_layout(wt_layout, borders=None, depth=None): fig = plt.figure(figsize=(6,6), dpi=2000) fs = 14 ax = plt.subplot(111) if depth is not None: N = 100 X, Y = plt.meshgrid(plt.linspace(depth[:,0].min(), depth[:,0].max(), N), plt.linspace(depth[:,1].min(), depth[:,1].max(), N)) Z = plt.griddata(depth[:,0],depth[:,1],depth[:,2],X,Y, interp='linear') plt.contourf(X,Y,Z, label='depth [m]') plt.colorbar().set_label('water depth [m]') #ax.plot(wt_layout.wt_positions[:,0], wt_layout.wt_positions[:,1], 'or', label='baseline position') ax.scatter(wt_layout.wt_positions[:,0], wt_layout.wt_positions[:,1], wt_layout._wt_list('rotor_diameter'), label='baseline position') if borders is not None: ax.plot(borders[:,0], borders[:,1], 'r--', label='border') ax.set_xlabel('x [m]'); ax.set_ylabel('y [m]') ax.axis('equal'); ax.legend(loc='lower left')
Example #3
Source File: image_ocr.py From pCVR with Apache License 2.0 | 6 votes |
def on_epoch_end(self, epoch, logs={}): self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch))) self.show_edit_distance(256) word_batch = next(self.text_img_gen)[0] res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words]) if word_batch['the_input'][0].shape[0] < 256: cols = 2 else: cols = 1 for i in range(self.num_display_words): pylab.subplot(self.num_display_words // cols, cols, i + 1) if K.image_data_format() == 'channels_first': the_input = word_batch['the_input'][i, 0, :, :] else: the_input = word_batch['the_input'][i, :, :, 0] pylab.imshow(the_input.T, cmap='Greys_r') pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i])) fig = pylab.gcf() fig.set_size_inches(10, 13) pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch))) pylab.close()
Example #4
Source File: model.py From facade-segmentation with MIT License | 6 votes |
def plot(self, overlay_alpha=0.5): import pylab as pl rows = int(sqrt(self.layers())) cols = int(ceil(self.layers()/rows)) for i in range(rows*cols): pl.subplot(rows, cols, i+1) pl.axis('off') if i >= self.layers(): continue pl.title('{}({})'.format(self.labels[i], i)) pl.imshow(self.image) pl.imshow(colorize(self.features[i].argmax(0), colors=np.array([[0, 0, 255], [0, 255, 255], [255, 255, 0], [255, 0, 0]])), alpha=overlay_alpha)
Example #5
Source File: image_ocr.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
def on_epoch_end(self, epoch, logs={}): self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch))) self.show_edit_distance(256) word_batch = next(self.text_img_gen)[0] res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words]) if word_batch['the_input'][0].shape[0] < 256: cols = 2 else: cols = 1 for i in range(self.num_display_words): pylab.subplot(self.num_display_words // cols, cols, i + 1) if K.image_data_format() == 'channels_first': the_input = word_batch['the_input'][i, 0, :, :] else: the_input = word_batch['the_input'][i, :, :, 0] pylab.imshow(the_input.T, cmap='Greys_r') pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i])) fig = pylab.gcf() fig.set_size_inches(10, 13) pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch))) pylab.close()
Example #6
Source File: image_ocr.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
def on_epoch_end(self, epoch, logs={}): self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch))) self.show_edit_distance(256) word_batch = next(self.text_img_gen)[0] res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words]) if word_batch['the_input'][0].shape[0] < 256: cols = 2 else: cols = 1 for i in range(self.num_display_words): pylab.subplot(self.num_display_words // cols, cols, i + 1) if K.image_data_format() == 'channels_first': the_input = word_batch['the_input'][i, 0, :, :] else: the_input = word_batch['the_input'][i, :, :, 0] pylab.imshow(the_input.T, cmap='Greys_r') pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i])) fig = pylab.gcf() fig.set_size_inches(10, 13) pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch))) pylab.close()
Example #7
Source File: image_ocr.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
def on_epoch_end(self, epoch, logs={}): self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch))) self.show_edit_distance(256) word_batch = next(self.text_img_gen)[0] res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words]) if word_batch['the_input'][0].shape[0] < 256: cols = 2 else: cols = 1 for i in range(self.num_display_words): pylab.subplot(self.num_display_words // cols, cols, i + 1) if K.image_data_format() == 'channels_first': the_input = word_batch['the_input'][i, 0, :, :] else: the_input = word_batch['the_input'][i, :, :, 0] pylab.imshow(the_input.T, cmap='Greys_r') pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i])) fig = pylab.gcf() fig.set_size_inches(10, 13) pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch))) pylab.close()
Example #8
Source File: image_ocr.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
def on_epoch_end(self, epoch, logs={}): self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch))) self.show_edit_distance(256) word_batch = next(self.text_img_gen)[0] res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words]) if word_batch['the_input'][0].shape[0] < 256: cols = 2 else: cols = 1 for i in range(self.num_display_words): pylab.subplot(self.num_display_words // cols, cols, i + 1) if K.image_data_format() == 'channels_first': the_input = word_batch['the_input'][i, 0, :, :] else: the_input = word_batch['the_input'][i, :, :, 0] pylab.imshow(the_input.T, cmap='Greys_r') pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i])) fig = pylab.gcf() fig.set_size_inches(10, 13) pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch))) pylab.close()
Example #9
Source File: image_ocr.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
def on_epoch_end(self, epoch, logs={}): self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch))) self.show_edit_distance(256) word_batch = next(self.text_img_gen)[0] res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words]) if word_batch['the_input'][0].shape[0] < 256: cols = 2 else: cols = 1 for i in range(self.num_display_words): pylab.subplot(self.num_display_words // cols, cols, i + 1) if K.image_data_format() == 'channels_first': the_input = word_batch['the_input'][i, 0, :, :] else: the_input = word_batch['the_input'][i, :, :, 0] pylab.imshow(the_input.T, cmap='Greys_r') pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i])) fig = pylab.gcf() fig.set_size_inches(10, 13) pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch))) pylab.close()
Example #10
Source File: image_ocr.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
def on_epoch_end(self, epoch, logs={}): self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch))) self.show_edit_distance(256) word_batch = next(self.text_img_gen)[0] res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words]) if word_batch['the_input'][0].shape[0] < 256: cols = 2 else: cols = 1 for i in range(self.num_display_words): pylab.subplot(self.num_display_words // cols, cols, i + 1) if K.image_data_format() == 'channels_first': the_input = word_batch['the_input'][i, 0, :, :] else: the_input = word_batch['the_input'][i, :, :, 0] pylab.imshow(the_input.T, cmap='Greys_r') pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i])) fig = pylab.gcf() fig.set_size_inches(10, 13) pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch))) pylab.close()
Example #11
Source File: fix_shot_times.py From nba-movement-data with MIT License | 6 votes |
def plot(t, plots, shot_ind): n = len(plots) for i in range(0,n): label, data = plots[i] plt = py.subplot(n, 1, i+1) plt.tick_params(labelsize=8) py.grid() py.xlim([t[0], t[-1]]) py.ylabel(label) py.plot(t, data, 'k-') py.scatter(t[shot_ind], data[shot_ind], marker='*', c='g') py.xlabel("Time") py.show() py.close()
Example #12
Source File: image_ocr.py From DeepLearning_Wavelet-LSTM with MIT License | 6 votes |
def on_epoch_end(self, epoch, logs={}): self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch))) self.show_edit_distance(256) word_batch = next(self.text_img_gen)[0] res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words]) if word_batch['the_input'][0].shape[0] < 256: cols = 2 else: cols = 1 for i in range(self.num_display_words): pylab.subplot(self.num_display_words // cols, cols, i + 1) if K.image_data_format() == 'channels_first': the_input = word_batch['the_input'][i, 0, :, :] else: the_input = word_batch['the_input'][i, :, :, 0] pylab.imshow(the_input.T, cmap='Greys_r') pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i])) fig = pylab.gcf() fig.set_size_inches(10, 13) pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch))) pylab.close()
Example #13
Source File: recipe-576501.py From code with MIT License | 6 votes |
def __init__(self, norder = 2): """Initializes the class when returning an instance. Pass it the polynomial order. It will set up two figure windows, one for the graph the other for the coefficent interface. It will then initialize the coefficients to zero and plot the (not so interesting) polynomial.""" self.order = norder self.c = M.zeros(self.order,'f') self.ax = [None]*(self.order-1)#M.zeros(self.order-1,'i') #Coefficent axes self.ffig = M.figure() #The first figure window has the plot self.replotf() self.cfig = M.figure() #The second figure window has the row = M.ceil(M.sqrt(self.order-1)) for n in xrange(self.order-1): self.ax[n] = M.subplot(row, row, n+1) M.setp(self.ax[n],'label', n) M.plot([0],[0],'.') M.axis([-1, 1, -1, 1]); self.replotc() M.connect('button_press_event', self.click_event)
Example #14
Source File: plot.py From TOPFARM with GNU Affero General Public License v3.0 | 6 votes |
def plot_wind_rose(wind_rose): fig = plt.figure(figsize=(12,5), dpi=1000) # Plotting the wind statistics ax1 = plt.subplot(121, polar=True) w = 2.*np.pi/len(wind_rose.frequency) b = ax1.bar(np.pi/2.0-np.array(wind_rose.wind_directions)/180.*np.pi - w/2.0, np.array(wind_rose.frequency)*100, width=w) # Trick to set the right axes (by default it's not oriented as we are used to in the WE community) mirror = lambda d: 90.0 - d if d < 90.0 else 360.0 + (90.0 - d) ax1.set_xticklabels([u'%d\xb0'%(mirror(d)) for d in linspace(0.0, 360.0,9)[:-1]]); ax1.set_title('Wind direction frequency'); # Plotting the Weibull A parameter ax2 = plt.subplot(122, polar=True) b = ax2.bar(np.pi/2.0-np.array(wind_rose.wind_directions)/180.*np.pi - w/2.0, np.array(wind_rose.A), width=w) ax2.set_xticklabels([u'%d\xb0'%(mirror(d)) for d in linspace(0.0, 360.0,9)[:-1]]); ax2.set_title('Weibull A parameter per wind direction sectors');
Example #15
Source File: horizontal_walking.py From pymanoid with GNU General Public License v3.0 | 5 votes |
def plot_mpc_preview(self): import pylab T = self.mpc_timestep h = stance.com.z g = -sim.gravity[2] trange = [sim.time + k * T for k in range(len(self.x_mpc.X))] pylab.ion() pylab.clf() pylab.subplot(211) pylab.plot(trange, [v[0] for v in self.x_mpc.X]) pylab.plot(trange, [v[0] - v[2] * h / g for v in self.x_mpc.X]) pylab.subplot(212) pylab.plot(trange, [v[0] for v in self.y_mpc.X]) pylab.plot(trange, [v[0] - v[2] * h / g for v in self.y_mpc.X])
Example #16
Source File: __init__.py From EDeN with MIT License | 5 votes |
def draw_graph_row(graphs, index=0, contract=True, n_graphs_per_line=5, size=4, xlim=None, ylim=None, **args): """draw_graph_row.""" dim = len(graphs) size_y = size size_x = size * n_graphs_per_line * args.get('size_x_to_y_ratio', 1) plt.figure(figsize=(size_x, size_y)) if xlim is not None: plt.xlim(xlim) plt.ylim(ylim) else: plt.xlim(xmax=3) for i in range(dim): plt.subplot(1, n_graphs_per_line, i + 1) graph = graphs[i] draw_graph(graph, size=None, pos=graph.graph.get('pos_dict', None), **args) if args.get('file_name', None) is None: plt.show() else: row_file_name = '%d_' % (index) + args['file_name'] plt.savefig(row_file_name, bbox_inches='tight', transparent=True, pad_inches=0) plt.close()
Example #17
Source File: plot_loss.py From ophelia with Apache License 2.0 | 5 votes |
def main_work(): ################################################# # ======== Get stuff from command line ========== a = ArgumentParser() a.add_argument('-o', dest='outfile', required=True) a.add_argument('-l', dest='logfile', required=True) opts = a.parse_args() # =============================================== log = readlist(opts.logfile) log = [line.split('|') for line in log] log = [line[3].strip() for line in log if len(line) >=4] #validation = [line.replace('validation epoch ', '') for line in log if line.startswith('validation epoch')] #train = [line.replace('train epoch ', '') for line in log if line.startswith('validation epoch')] validation = [line.split(':')[1].strip().split(' ') for line in log if line.startswith('validation epoch')] train = [line.split(':')[1].strip().split(' ') for line in log if line.startswith('train epoch')] validation = np.array(validation, dtype=float) train = np.array(train, dtype=float) print train.shape print validation.shape pl.subplot(211) pl.plot(validation.flatten()) pl.subplot(212) pl.plot(train[:,:4]) pl.show()
Example #18
Source File: tools.py From Motiftoolbox with GNU General Public License v2.0 | 5 votes |
def plot_phase_3D(phase_1, phase_2, phase_3, axes, **kwargs): from pylab import plot, subplot if "PI" in kwargs: PI = kwargs.pop('PI') else: PI = np.pi #assert isinstance(Axes3D) dphi_1, dphi_2, dphi_3 = phase_1[1:]-phase_1[:-1], phase_2[1:]-phase_2[:-1], phase_3[1:]-phase_3[:-1] j0 = 0 for j in xrange(1, phase_1.size): if abs(dphi_1[j-1]) < PI and abs(dphi_2[j-1]) < PI and abs(dphi_3[j-1]) < PI: continue else: x, y, z = phase_1[j0:j], phase_2[j0:j], phase_3[j0:j] try: axes.plot(x, y, z, '-', **kwargs) except: pass j0 = j try: x, y, z = phase_1[j0:], phase_2[j0:], phase_3[j0:] axes.plot(x, y, z, '-', **kwargs) except: pass
Example #19
Source File: fusion_dwb.py From ImageFusion with MIT License | 5 votes |
def plot(self): plt.figure(0) plt.gray() plt.subplot(131) plt.imshow(self._images[0]) plt.subplot(132) plt.imshow(self._images[1]) plt.subplot(133) plt.imshow(self._fusionImage) plt.show()
Example #20
Source File: fusion_pca.py From ImageFusion with MIT License | 5 votes |
def plot(self): plt.figure(0) plt.gray() plt.subplot(131) plt.imshow(self._images[0]) plt.subplot(132) plt.imshow(self._images[1]) plt.subplot(133) plt.imshow(self._fusionImage) plt.show()
Example #21
Source File: util.py From face-magnet with Apache License 2.0 | 5 votes |
def drawModel(mfeat, mode="black", parts=True): """ draw the HOG weight of an object model """ col = ["r", "g", "b"] import drawHOG lev = len(mfeat) if mfeat[0].shape[0] > mfeat[0].shape[1]: sy = 1 sx = lev else: sy = lev sx = 1 for l in range(lev): pylab.subplot(sy, sx, l + 1) if mode == "white": drawHOG9(mfeat[l]) elif mode == "black": img = drawHOG.drawHOG(mfeat[l]) pylab.axis("off") pylab.imshow(img, cmap=pylab.cm.gray, interpolation="nearest") if parts == True: for x in range(0, 2 ** l): for y in range(0, 2 ** l): boxHOG(mfeat[0].shape[1] * x, mfeat[0].shape[0] * y, mfeat[0].shape[1], mfeat[0].shape[0], col[l], 5 - l)
Example #22
Source File: epipolar.py From dfc2019 with MIT License | 5 votes |
def show_rectified_images(rimg1, rimg2): ax = pl.subplot(121) pl.imshow(rimg1, cmap=cm.gray) # Hack to get the lines span on the left image # http://stackoverflow.com/questions/6146290/plotting-a-line-over-several-graphs for i in range(1, rimg1.shape[0], int(rimg1.shape[0]/20)): pl.axhline(y=i, color='g', xmin=0, xmax=1.2, clip_on=False); pl.subplot(122) pl.imshow(rimg2, cmap=cm.gray) for i in range(1, rimg1.shape[0], int(rimg1.shape[0]/20)): pl.axhline(y=i, color='g');
Example #23
Source File: plots.py From ColorPy with GNU Lesser General Public License v2.1 | 5 votes |
def cie_matching_functions_plot (): '''Plot the CIE XYZ matching functions, as three spectral subplots.''' # get 'spectra' for x,y,z matching functions spectrum_x = ciexyz.empty_spectrum() spectrum_y = ciexyz.empty_spectrum() spectrum_z = ciexyz.empty_spectrum() (num_wl, num_cols) = spectrum_x.shape for i in range (0, num_wl): wl_nm = spectrum_x [i][0] xyz = ciexyz.xyz_from_wavelength (wl_nm) spectrum_x [i][1] = xyz [0] spectrum_y [i][1] = xyz [1] spectrum_z [i][1] = xyz [2] # Plot three separate subplots, with CIE X in the first, CIE Y in the second, and CIE Z in the third. # Label appropriately for the whole plot. pylab.clf () # X pylab.subplot (3,1,1) pylab.title ('1931 CIE XYZ Matching Functions') pylab.ylabel ('CIE $X$') spectrum_subplot (spectrum_x) tighten_x_axis (spectrum_x [:,0]) # Y pylab.subplot (3,1,2) pylab.ylabel ('CIE $Y$') spectrum_subplot (spectrum_y) tighten_x_axis (spectrum_x [:,0]) # Z pylab.subplot (3,1,3) pylab.xlabel ('Wavelength (nm)') pylab.ylabel ('CIE $Z$') spectrum_subplot (spectrum_z) tighten_x_axis (spectrum_x [:,0]) # done filename = 'CIEXYZ_Matching' print ('Saving plot %s' % str (filename)) pylab.savefig (filename)
Example #24
Source File: orbit.py From Motiftoolbox with GNU General Public License v2.0 | 5 votes |
def show(self, ax=None): from pylab import subplot, plot, show if ax == None: ax = subplot(111) phase = np.arange(0., 2.*np.pi+0.01, 0.01) X = self.evaluate_orbit(phase) ax.plot(phase, X[0]) ax.plot(phase, X[1])
Example #25
Source File: sound.py From multisensory with Apache License 2.0 | 5 votes |
def test_spectrogram(): # http://matplotlib.org/examples/pylab_examples/specgram_demo.html dt = 1./0.0005 t = np.arange(0., 20., dt) #t = np.arange(0., 3., dt) s1 = np.sin((2*np.pi)*100*t) s2 = 2 * np.sin((2*np.pi)*400*t) s2[-((10 < t) & (t < 12))] = 0 nse = 0.01 * np.random.randn(len(t)) if 0: x = s1 else: x = s1 + s2 + nse freqs, spec, spec_times = make_specgram(x, dt) pl.clf() ax1 = pl.subplot(211) ax1.plot(t, x) if 1: lsp = spec.copy() lsp[spec > 0] = np.log(spec[spec > 0]) lsp = ut.clip_rescale(lsp, -10, np.percentile(lsp, 99)) else: lsp = spec.copy() lsp = ut.clip_rescale(lsp, 0, np.percentile(lsp, 99)) ax2 = pl.subplot(212, sharex = ax1) ax2.imshow(lsp.T, cmap = pl.cm.jet, extent = (0., t[-1], np.min(freqs), np.max(freqs)), aspect = 'auto') ig.show(vis_specgram(freqs, spec, spec_times)) ut.toplevel_locals()
Example #26
Source File: dataset_float_classes.py From DEMUD with Apache License 2.0 | 5 votes |
def plot_item(self, m, ind, x, r, k, label, U, rerr, feature_weights): if x == [] or r == []: print "Error: No data in x and/or r." return pylab.clf() # xvals, x, and r need to be column vectors # xvals represent bin end points, so we need to duplicate most of them x = np.repeat(x, 2, axis=0) r = np.repeat(r, 2, axis=0) pylab.subplot(2,1,1) pylab.semilogx(self.xvals, r[0:128], 'r-', label='Expected') pylab.semilogx(self.xvals, x[0:128], 'b.-', label='Observations') pylab.xlabel('CTN: ' + self.xlabel) pylab.ylabel(self.ylabel) pylab.legend(loc='upper left', fontsize=10) pylab.subplot(2,1,2) pylab.semilogx(self.xvals, r[128:], 'r-', label='Expected') pylab.semilogx(self.xvals, x[128:], 'b.-', label='Observations') pylab.xlabel('CETN: ' + self.xlabel) pylab.ylabel(self.ylabel) pylab.legend(loc='upper left', fontsize=10) pylab.suptitle('DEMUD selection %d (%s), item %d, using K=%d' % \ (m, label, ind, k)) outdir = os.path.join('results', self.name) if not os.path.exists(outdir): os.mkdir(outdir) figfile = os.path.join(outdir, 'sel-%d-k-%d-(%s).pdf' % (m, k, label)) pylab.savefig(figfile) print 'Wrote plot to %s' % figfile pylab.close()
Example #27
Source File: megafacade.py From facade-segmentation with MIT License | 5 votes |
def plot_facade_cuts(self): facade_sig = self.facade_edge_scores.sum(0) facade_cuts = find_facade_cuts(facade_sig, dilation_amount=self.facade_merge_amount) mu = np.mean(facade_sig) sigma = np.std(facade_sig) w = self.rectified.shape[1] pad=10 gs1 = pl.GridSpec(5, 5) gs1.update(wspace=0.5, hspace=0.0) # set the spacing between axes. pl.subplot(gs1[:3, :]) pl.imshow(self.rectified) pl.vlines(facade_cuts, *pl.ylim(), lw=2, color='black') pl.axis('off') pl.xlim(-pad, w+pad) pl.subplot(gs1[3:, :], sharex=pl.gca()) pl.fill_between(np.arange(w), 0, facade_sig, lw=0, color='red') pl.fill_between(np.arange(w), 0, np.clip(facade_sig, 0, mu+sigma), color='blue') pl.plot(np.arange(w), facade_sig, color='blue') pl.vlines(facade_cuts, facade_sig[facade_cuts], pl.xlim()[1], lw=2, color='black') pl.scatter(facade_cuts, facade_sig[facade_cuts]) pl.axis('off') pl.hlines(mu, 0, w, linestyle='dashed', color='black') pl.text(0, mu, '$\mu$ ', ha='right') pl.hlines(mu + sigma, 0, w, linestyle='dashed', color='gray',) pl.text(0, mu + sigma, '$\mu+\sigma$ ', ha='right') pl.xlim(-pad, w+pad)
Example #28
Source File: analyser.py From spotpy with MIT License | 5 votes |
def plot_gelman_rubin(r_hat_values,fig_name='gelman_rub.png'): '''Input: List of R_hat values of chains (see Gelman & Rubin 1992) Output: Plot as seen for e.g. in (Sadegh and Vrugt 2014)''' import matplotlib.pyplot as plt fig=plt.figure(figsize=(16,9)) ax = plt.subplot(1,1,1) ax.plot(r_hat_values) ax.plot([1.2]*len(r_hat_values),'k--') ax.set_xlabel='r_hat' plt.savefig(fig_name,dpi=300)
Example #29
Source File: analyser.py From spotpy with MIT License | 5 votes |
def plot_allmodelruns(modelruns,observations,dates=None, fig_name='bestmodel.png'): '''Input: Array of modelruns and list of Observations Output: Plot with all modelruns as a line and dots with the Observations ''' import matplotlib.pyplot as plt fig=plt.figure(figsize=(16,9)) ax = plt.subplot(1,1,1) if dates is not None: for i in range(len(modelruns)): if i==0: ax.plot(dates, modelruns[i],'b',alpha=.05,label='Simulations') else: ax.plot(dates, modelruns[i],'b',alpha=.05) else: for i in range(len(modelruns)): if i==0: ax.plot(modelruns[i],'b',alpha=.05,label='Simulations') else: ax.plot(modelruns[i],'b',alpha=.05) ax.plot(observations,'ro',label='Evaluation') ax.legend() ax.set_xlabel = 'Best model simulation' ax.set_ylabel = 'Evaluation points' ax.set_title = 'Maximum objectivefunction of Simulations' fig.savefig(fig_name) text='The figure as been saved as '+fig_name print(text)
Example #30
Source File: analyser.py From spotpy with MIT License | 5 votes |
def plot_posterior_parametertrace(results,parameternames=None,threshold=0.1, fig_name='Posterior_parametertrace.png'): """ Get a plot with all values of a given parameter in your result array. The plot will be saved as a .png file. :results: Expects an numpy array which should of an index "like" for objectivefunctions :type: array :parameternames: A List of Strings with parameternames. A line object will be drawn for each String in the List. :type: list :return: Plot of all traces of the given parameternames. :rtype: figure """ import matplotlib.pyplot as plt fig=plt.figure(figsize=(16,9)) results=sort_like(results) if not parameternames: parameternames=get_parameternames(results) names='' i=1 for name in parameternames: ax = plt.subplot(len(parameternames),1,i) ax.plot(results['par'+name][int(len(results)*threshold):],label=name) names+=name+'_' ax.set_ylabel(name) if i==len(parameternames): ax.set_xlabel('Repetitions') if i==1: ax.set_title('Parametertrace') ax.legend() i+=1 fig.savefig(fig_name) text='The figure as been saved as '+fig_name print(text)