tuplelist = [ (p, d) for p, d in data.items()\ if max(d['cases']) >= 20\ and len(np.where(np.logical_and(np.array(d['times'])<=12, np.array(d['cases'])>0))[0])\ >= 8 ] colors tuplelist = sorted([t for t in tuplelist], key=lambda x: -max(x[1]['cases'])) n_fits = len(tuplelist) n_col = int(np.ceil(np.sqrt(n_fits))) n_row = 2 n_col = 4 fig, ax = pl.subplots(n_row, n_col, figsize=(8, 3)) ax = ax.flatten() titlemap = REPL({'mainland_china': 'All w/o Hubei'}) letter = "abcdefg" roman = ["i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"] i = -1 for province, pdata in tqdm(tuplelist[2:10]): i += 1 print(province) t = np.array(pdata['times']) cases = np.array(pdata['cases']) if pdata['dates'][0] == "2020-01-22 12:00:00":
if loaded_fits: with open(pickle_filename, 'rb') as f: fit_parameters = pickle.load(f) else: fit_parameters = {} letter = "abcdefg" roman = ["i", "ii", "iii", "iv", "v", "vi"] ylims = [[100, 100000], [10, 20000]] max_dates = ['Feb. 7th', 'Feb. 1st.'] max_dates_pos = [60000, 15000] max_dates_va = ['bottom'] * 2 i = -1 fig, ax = pl.subplots(1, 2, figsize=(3.5, 2)) curves = {} for province, pdata in tqdm(tuplelist[:2]): i += 1 t = np.array(pdata['times']) cases = np.array(pdata['cases']) dates = np.array(pdata['dates'], np.datetime64) if max(cases) <= 20: continue i0 = np.where(cases > 0)[0][0] t = t[i0:] cases = cases[i0:]
and len(np.where(np.logical_and(np.array(d['times'])<=12, np.array(d['cases'])>0))[0])\ >= 8 ] tuplelist = sorted([t for t in tuplelist], key=lambda x: -max(x[1]['cases'])) loaded_fits = len(sys.argv) > 1 if loaded_fits: pickle_filename = sys.argv[1] n_fits = len(tuplelist) n_col = int(np.ceil(np.sqrt(n_fits))) n_row = n_col n_col = n_col - 1 fig, ax = pl.subplots(n_row, n_col, figsize=(10, 10)) ax = ax.flatten() titlemap = REPL({'mainland_china': 'All exc. Hubei'}) if loaded_fits: with open(pickle_filename, 'rb') as f: fit_parameters = pickle.load(f) else: fit_parameters = {} letter = "abcdefg" roman = ["i", "ii", "iii", "iv", "v", "vi"] i = -1 for province, pdata in tqdm(tuplelist):
if data_exists: data = np.load('data/clustering_data.npz') clustering_k = data['clustering_k'] clustering_n = data['clustering_n'] clustering_r = data['clustering_r'] clustering_T = data['clustering_T'] data_arrays = [clustering_k, clustering_n, clustering_r, clustering_T] matplotlib.rcParams['font.size'] = 12 ### triangle plots fig, axes = pl.subplots( 1, 4, figsize=(12, 3), #sharey=True ) ## axes[0].set_xlabel(r'mean degree $\left\langle k\right\rangle$') axes[0].set_ylabel(r'clustering coefficient $C$') for ax in axes: ax.set_yscale('log') for ax in axes[:2]: ax.set_xscale('log') axes[3].set_xscale('log')
### variance plot n = 10**5 NMAX = 20 rho = np.linspace(0.0, 0.5, 200) k = 2**np.arange(0, 10, 2) k = np.array(k, dtype=float) if not data_exists: variances = np.zeros((len(rho), len(k))) for i in range(len(rho)): for j in range(len(k)): t = solve_t(k[j], n) variances[i, j] = variance(t, rho[i], n, NMAX) fig, ax = pl.subplots(1, 1, figsize=(4, 2.5)) pl.xlabel(r'local edge weight correlation $\rho$') pl.ylabel(r'node degree variance $\mathrm{Var}(k)$') for i in range(len(k)): pl.plot(rho, variances[:, i], c=bp.brewer_qualitative[1]) bp.strip_axis(ax) ax.set_yscale('log') #ax.set_xscale('log') ax.set_xlim([0, 0.5]) fig.tight_layout() for i in range(len(k)): bp.add_curve_label(ax, rho,
letter = "abcdefg" roman = ["i", "ii", "iii", "iv", "v", "vi"] ylims = [[0, 64000], [0, 15000]] max_dates = ['Feb. 7th', 'Feb. 2nd'] hand_len = [2, 0.5] max_dates_pos = [29000, 9000] max_dates_va = ['bottom'] * 2 change_dates_pos = [46000, 11000] change_dates_label_pos = [5000, 4000] change_dates_label_ha = ['center', 'right'] change_dates_va = ['bottom'] * 2 i = -1 fig, ax = pl.subplots(1, 2, figsize=(8, 3)) curves = {} for province, pdata in tqdm(tuplelist[:2]): i += 1 t = np.array(pdata['times']) cases = np.array(pdata['cases']) dates = np.array(pdata['dates'], np.datetime64) if max(cases) <= 20: continue i0 = np.where(cases > 0)[0][0] tswitch = t[-1] t = t[i0:] cases = cases[i0:]
tuplelist = [ (p, d) for p, d in data.items()\ if max(d['cases']) >= 20\ and len(np.where(np.logical_and(np.array(d['times'])<=12, np.array(d['cases'])>0))[0])\ >= 8 ] colors tuplelist = sorted([t for t in tuplelist], key=lambda x: -max(x[1]['cases'])) n_fits = len(tuplelist) n_col = int(np.ceil(np.sqrt(n_fits))) n_row = 1 n_col = 2 fig, ax = pl.subplots(n_row, n_col, figsize=(3, 2)) ax = ax.flatten() titlemap = REPL({'mainland_china': 'All w/o Hubei'}) letter = "abcdefg" roman = ["i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"] i = -1 for province, pdata in tqdm(tuplelist[:2]): i += 1 print(province) t = np.array(pdata['times']) cases = np.array(pdata['cases'])
'x': ax.set_xticks, 'y': ax.set_yticks, } for _ax in axes.lower(): lim = get_lims[_ax]() Ticks = NiceTicks(*lim) set_lims[_ax](Ticks.lim) set_ticks[_ax](Ticks.ticks) if __name__ == "__main__": import numpy as np import bfmplot as bp fig, ax = pl.subplots(1, 1) x = np.linspace(1, 10, 100) mus = np.linspace(1, 4, 4) for mu in mus: y = x**mu pl.plot(x, y, c=bp.brewer_qualitative[0]) #pl.xscale('log') bp.strip_axis(ax, horizontal='left') pl.yscale('log') ax.set_xlabel('x') ax.set_ylabel('y') pl.gcf().tight_layout()
"""Simplest implementation of a list with periodic boundary conditions""" def __init__(self,items): self.items = items def __getitem__(self,i): return self.items[i%len(self.items)] #markers = simple_cycler(['s','d','o','v','*','^','.','>','h','p','P','<','8','H','X']) markers = simple_cycler(['s','d','o','v','*','^','>','h','p','P','<','8','H','X']) if __name__ == "__main__": import numpy as np seq = wong_order ncol = int(np.ceil(np.sqrt(len(seq)))) fig, ax = pl.subplots(ncol,ncol,figsize=(8,8)) ax = ax.flatten() x = np.linspace(0,2*np.pi,1000) for i in range(len(seq)): for j in range(i+1): ax[i].plot(x,np.sin(x*np.sqrt(j+1)),c=seq[j],lw=3) pl.show()
from load_data import data import qsuite_config as cf import numpy as np import bfmplot as bp from bfmplot import pl import matplotlib as mpl from matplotlib.ticker import MaxNLocator mpl.rcParams['font.size'] = 9 ks = cf.ks ns = cf.ns rhos = cf.rhos fig, axes = pl.subplots(1, 2, figsize=(8, 2.5)) LEGN = 0 LEGK = 0 RHON = 0 RHOK = 2 labels = ['0', '0.05', '0.15', '0.5'] pos = [67, 3.5, 2, 2] ax = axes[0] for iax, ax in enumerate(axes): for i_n, n in enumerate(ns): for i_mk, mk in enumerate(ks): for i_rho, rho in enumerate(rhos):
tuplelist = [ (p, d) for p, d in data.items()\ if max(d['cases']) >= 20\ and len(np.where(np.logical_and(np.array(d['times'])<=12, np.array(d['cases'])>0))[0])\ >= 8 ] colors tuplelist = sorted([t for t in tuplelist], key=lambda x: -max(x[1]['cases'])) n_fits = len(tuplelist) n_col = int(np.ceil(np.sqrt(n_fits))) n_row = 1 n_col = 2 fig, ax = pl.subplots(n_row, n_col, figsize=(8, 3), sharex=True) ax = ax.flatten() titlemap = REPL({'mainland_china': 'all except Hubei'}) letter = "abcdefg" roman = ["i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"] i = -1 for province, pdata in tqdm(tuplelist[:2]): i += 1 print(province) t = np.array(pdata['times']) cases = np.array(pdata['cases']) dates = np.array(pdata['dates'], dtype=np.datetime64)