def plot_pdf(scatter, gobs, atoms, save_file=None, show=True, **kwargs): fig = plt.figure() ax = fig.add_subplot(111) gcalc = scatter.get_pdf(atoms) r = scatter.get_r() rw, scale = wrap_rw(gcalc, gobs) print 'Rw', rw * 100, '%' baseline = -1 * np.abs(1.5 * gobs.min()) gdiff = gobs - gcalc * scale ax.plot(r, gobs, 'bo', label="G(r) data") ax.plot(r, gcalc * scale, 'r-', label="G(r) fit") ax.plot(r, gdiff + baseline, 'g-', label="G(r) diff") ax.plot(r, np.zeros_like(r) + baseline, 'k:') ax.set_xlabel(r"$r (\AA)$") ax.set_ylabel(r"$G (\AA^{-2})$") plt.legend(loc='best', prop={'size': 12}) if save_file is not None: plt.savefig(save_file + '_pdf.eps', bbox_inches='tight', transparent='True') plt.savefig(save_file + '_pdf.png', bbox_inches='tight', transparent='True') if show is True: plt.show() return
def plot_waterfall_diff_pdf_2d(scatter, gobs, traj, save_file=None, show=True, **kwargs): fig = plt.figure() ax = fig.add_subplot(111) r = scatter.get_r() # ax.plot(r, gobs, 'bo', label="G(r) data") gcalcs = [] for i, atoms in enumerate(traj): gcalc = scatter.get_pdf(atoms) rw, scale = wrap_rw(gcalc, gobs) print i, 'Rw', rw * 100, '%' gcalcs.append(gobs - gcalc * scale) ax.imshow(gcalcs, aspect='auto', origin='lower', extent=(r.min(), r.max(), 0, len(traj))) ax.set_xlabel(r"$r (\AA)$") ax.set_ylabel("iteration") ax.legend(loc='best', prop={'size': 12}) if save_file is not None: plt.savefig(save_file + '_2d_water_diff_pdf.eps', bbox_inches='tight', transparent='True') plt.savefig(save_file + '_2d_water_diff_pdf.png', bbox_inches='tight', transparent='True') if show is True: plt.show() return
def plot_waterfall_diff_pdf(scatter, gobs, traj, save_file=None, show=True, **kwargs): fig = plt.figure() ax = fig.add_subplot(111) r = scatter.get_r() # ax.plot(r, gobs, 'bo', label="G(r) data") for i, atoms in enumerate(traj): gcalc = scatter.get_pdf(atoms) rw, scale = wrap_rw(gcalc, gobs) print i, 'Rw', rw * 100, '%' plt.plot( r, gobs - (gcalc * scale) # - i , '-', label="Fit {}".format(i)) ax.set_xlabel(r"$r (\AA)$") ax.set_ylabel(r"$G (\AA^{-2})$") ax.legend(loc='best', prop={'size': 12}) if save_file is not None: plt.savefig(save_file + '_pdf.eps', bbox_inches='tight', transparent='True') plt.savefig(save_file + '_pdf.png', bbox_inches='tight', transparent='True') if show is True: plt.show() return
def plot_waterfall_pdf(scatter, gobs, traj, save_file=None, show=True, **kwargs): fig = plt.figure() ax = fig.add_subplot(111) r = scatter.get_r() # ax.plot(r, gobs, 'bo', label="G(r) data") for i, atoms in enumerate(traj): gcalc = scatter.get_pdf(atoms) rw, scale = wrap_rw(gcalc, gobs) print i, 'Rw', rw * 100, '%' plt.plot(r, gcalc * scale + i, '-', label="Fit {}".format(i)) ax.set_xlabel(r"$r (\AA)$") ax.set_ylabel(r"$G (\AA^{-2})$") ax.legend(loc='best', prop={'size': 12}) if save_file is not None: plt.savefig(save_file + '_pdf.eps', bbox_inches='tight', transparent='True') plt.savefig(save_file + '_pdf.png', bbox_inches='tight', transparent='True') if show is True: plt.show() return
os.makedirs(save_folder) # ''' plot_temp_1d_data(Ts, data_list=data_list, x_lims=xlims, save_path=save_folder, plot_type=plot_type, save=True, plot=False, offset=offset ) # ''' # ''' rws = np.zeros((len(data_list), len(data_list))) print(Ts.shape) for i in range(len(data_list)): for j in range(len(data_list)): rws[i, j] = wrap_rw(data_list[i][1], data_list[j][1])[0] * 100 fig, ax = plt.subplots() im = ax.imshow(rws, interpolation='none', cmap='viridis', # aspect='auto', origin='lower left') xticks = np.asarray(ax.get_xticks(), dtype=int) tsxt = Ts[xticks[1:-1]] tsxt = np.reshape(tsxt, len(tsxt)) for s in range(len(tsxt)): tsxt[s] = float(Decimal(np.round(tsxt[s], 0)).quantize(Decimal('1.'))) xtl = [''] xtl.extend(tsxt.astype(int).tolist()) xtl.append('') ax.set_xticklabels(xtl) ax.set_yticklabels(xtl)
fig.savefig( os.path.join( dest, "S{}-{}_{}_{}_{}{}.{}".format( min(ns), max(ns), length, event_name, output, zz, fmt ), ) ) if plot: plt.show() else: plt.close(fig) rws = np.zeros((len(datas), len(datas))) for i in range(len(datas)): for j in range(len(datas)): rws[i, j] = wrap_rw(np.nan_to_num(datas[i][1]), np.nan_to_num(datas[j][1]))[0] * 100 fig, ax = plt.subplots() im = ax.imshow( rws, interpolation="none", cmap="viridis", # aspect='auto', origin="lower left", ) xtl = [""] xtl.extend(names) xtl.append("") ax.set_xticklabels([""] * len(xtl)) ax.set_yticklabels(xtl) cbar = fig.colorbar(im) print(event_name)