def main(argv): argsf = {'func':['-li'], 'files':['simdata/svcsimn_d2a1_6.json', 'simdata/svcsimn_d3a1_2.json', 'simdata/svcsimn_d4a1_2.json'], '-m':['red'], '-yl':['$P(k_{in})$'], '-axisfsize':['large'], '-lb':[1.21], '-gl':[0], '-loc':[1], '-l':['sf, $\langle{dep}\\rangle = 1$', 'sf, $\langle{dep}\\rangle \\approx 1.5$', 'sf, $\langle{dep}\\rangle \\approx 2$']} argexp = {'func':['-di'], 'files':['simdata/expsvcsimn_d2a1_5.json', 'simdata/expsvcsimn_d3a1_2.json', 'simdata/expsvcsimn_d4a1_3.json'], '-m':['blue'], '-xl':['In-degree $k_{in}$'], '-axisfsize':['large'], '-logy':[1], '-l':['exp, $\langle{dep}\\rangle = 1$', 'exp, $\langle{dep}\\rangle \\approx 1.5$', 'exp, $\langle{dep}\\rangle \\approx 2$']} argrand = {'func':['-di'], 'files':['simdata/randsvcsimn_d2a1_5.json', 'simdata/randsvcsimn_d3a1_2.json', 'simdata/randsvcsimn_d4a1_3.json'], '-m':['yellow'], '-axisfsize':['large'], '-l':['rand, $\langle{dep}\\rangle = 1$', 'rand, $\langle{dep}\\rangle \\approx 1.5$', 'rand, $\langle{dep}\\rangle \\approx 2$']} p.plt.subplot(131) p.drawloglogdist(pl.loadarg([argsf]) , xlabel=pl.getargval(argsf, '-xl', [''])[0] , ylabel=pl.getargval(argsf, '-yl', [''])[0] , title=pl.getargval(argsf, '-t', [''])[0] , markset=pl.getargval(argsf, '-m', ['var'])[0] , xlim=pl.getargval(argsf, '-xlim') , ylim=pl.getargval(argsf, '-ylim') , axisfsize=pl.getaxisfsize(argsf) , logbinbase=pl.getargval(argsf, '-lb', [1.21])[0] , showexp=int(pl.getargval(argsf, '-g', [1])[0]) , legloc=int(pl.getargval(argsf, '-loc', [1])[0]) , isexpline=int(pl.getargval(argsf, '-gl', [1])[0])) legend = p.plt.legend(argsf['-l'], labelspacing=0.1, numpoints=1) p.plt.setp(legend.get_texts(), fontsize=12) p.plt.subplot(132) logx, logy = pl.getlogparam(argexp) p.plotdegdist(pl.loadarg([argexp]) , markset=pl.getargval(argexp, '-m', ['var'])[0] , title=pl.getargval(argexp, '-t', [''])[0] , xylabels={'x': pl.getargval(argexp, '-xl', [''])[0], 'y': pl.getargval(argexp, '-yl', [''])[0]} , nbins=int(pl.getargval(argexp, '-b', ['50'])[0]) , logx=logx, logy=logy , xlim=pl.getargval(argexp, '-xlim') , ylim=pl.getargval(argexp, '-ylim') , legloc=int(pl.getargval(argexp, '-loc', [2])[0]) , axisfsize=pl.getaxisfsize(argexp)) legend = p.plt.legend(argexp['-l'], labelspacing=0.1, numpoints=1) p.plt.setp(legend.get_texts(), fontsize=12) p.plt.subplot(133) logx, logy = pl.getlogparam(argrand) p.plotdegdist(pl.loadarg([argrand]) , markset=pl.getargval(argrand, '-m', ['var'])[0] , title=pl.getargval(argrand, '-t', [''])[0] , xylabels={'x': pl.getargval(argrand, '-xl', [''])[0], 'y': pl.getargval(argrand, '-yl', [''])[0]} , nbins=int(pl.getargval(argrand, '-b', ['50'])[0]) , logx=logx, logy=logy , xlim=pl.getargval(argrand, '-xlim') , ylim=pl.getargval(argrand, '-ylim') , legloc=int(pl.getargval(argrand, '-loc', [2])[0]) , axisfsize=pl.getaxisfsize(argrand)) lines = p.plt.gca().get_lines() for line in lines: p.plt.setp(line, markerfacecolor='orange') legend = p.plt.legend(argrand['-l'], labelspacing=0.1, numpoints=1) p.plt.setp(legend.get_texts(), fontsize=12) p.plt.gcf().suptitle('In-degree distribution of scale-free, exponential, and random service networks', fontsize=14) p.processplot(p.plt)
def main(argv): lsarg = [] lsarg.append({'func':['-di'], 'files':['simdata/lg_comp.json'], '-m':['star'], '-t':['In-degree distribution of the Language Grid and ProgrammableWeb service networks'], '-xl':['In-degree $k_{in}$'], '-yl':['Probability distribution $P(k_{in})$\nThe Language Grid'], '-l':['The Language Grid'], '-loc':[2], '-axisfsize':['large'], '-logx':[1], '-logy':[1]}) lsarg.append({'func':['-li'], 'files':['simdata/pwsvcsim_1.json'], '-m':['diamond'], '-yl':['ProgrammableWeb'], '-l':['ProgrammableWeb'], '-axisfsize':['large'], '-loc':[4], '-lb':[1.21], '-xlim':[-1,10000], '-logx':[1], '-logy':[1]}) ax = p.plt.axes([0.13, 0.12, 0.6, 0.78]) ax2 = p.plt.twinx(ax) for i in range(len(lsarg)): ds = [] func = lsarg[i]['func'][0] step = p.STEP argstep = getargval(lsarg[i], '-j') if argstep: step = int(argstep[0]) for finjson in lsarg[i]['files']: f = open(finjson) try: data = json.load(f) p.loaddata(ds, func, data, finjson, step) finally: f.close() logx = False arglogx = getargval(lsarg[i], '-logx') if arglogx: logx = int(arglogx[0]) > 0 logy = False arglogy = getargval(lsarg[i], '-logy') if arglogy: logy = int(arglogy[0]) > 0 lb = p.LOGBINBASE arglb = getargval(lsarg[i], '-lb') if arglb: lb = float(arglb[0]) xlim = getargval(lsarg[i], '-xlim') ylim = getargval(lsarg[i], '-ylim') plotfile = getargval(lsarg[i], '-v', [None])[0] axisfsize = getargval(lsarg[i], '-axisfsize', ['medium'])[0] try: axisfsize = int(axisfsize) except: pass if i == 0: #func == p.FUNC_DISTINDEG: p.plotdegdist(ds , getargval(lsarg[i], '-l') , getargval(lsarg[i], '-m', ['var'])[0] , title=getargval(lsarg[i], '-t', [''])[0] , xylabels={'x': getargval(lsarg[i], '-xl', [''])[0], 'y': getargval(lsarg[i], '-yl', [''])[0]} , nbins=int(getargval(lsarg[i], '-b', ['50'])[0]) , logx=logx, logy=logy , xlim=xlim , ylim=ylim , legloc=int(getargval(lsarg[i], '-loc', [2])[0]) , axisfsize=axisfsize , ax=ax) #, ax=p.plt.twinx(p.plt.gca())) #, ax=p.plt.gca()) ax.set_ylabel(ax.get_ylabel(), color='#460046') for tl in ax.get_yticklabels(): tl.set_color('#460046') elif i == 1: #func == p.FUNC_LOGINDEG: p.drawloglogdist(ds , xlabel=getargval(lsarg[i], '-xl', [''])[0] , ylabel=getargval(lsarg[i], '-yl', [''])[0] , title=getargval(lsarg[i], '-t', [''])[0] , labels=getargval(lsarg[i], '-l') , markset=getargval(lsarg[i], '-m', ['var'])[0] , xlim=xlim , ylim=ylim , axisfsize=axisfsize , legloc=int(getargval(lsarg[i], '-loc', [2])[0]) , logbinbase=lb , showexp=int(getargval(lsarg[i], '-g', [1])[0]) , ax=ax2) #, ax=p.plt.twinx(ax)) #, ax=p.plt.twinx(p.plt.gca())) ax2.set_ylabel(ax2.get_ylabel(), color='#003200') for tl in ax2.get_yticklabels(): tl.set_color('#003200') p.processplot(p.plt, getargval(lsarg[i], '-s', [None])[0])
def main(argv): lsarg = [] lsarg.append({'func':['-li'], 'files':['simdata/svcsimn_10k_10k_d2_a7_i10_avg1_8.json'], '-m':['reddia'], '-l':['scale-free'], '-g':[0], '-lb':['1.21']}) lsarg.append({'func':['-di'], 'files':['simdata/expsvcsimn_10k_10k_d2_a7_i10_avg1_8.json'], '-m':['bluepenta'], '-b':['100'], '-l':['exponential']}) lsarg.append({'func':['-di'], 'files':['simdata/randsvcsimn_10k_10k_d2_a11_i10_avg1_8.json'], '-m':['trihexaorg'], '-b':['100'], '-l':['random'], '-logx':[1], '-logy':[1], '-xlim':[1, 500], '-ylim':[1e-6, 1], '-t':['Scale-free, exponential, and random network degree distribution'], '-xl':['In-degree $k_{in}$'], '-yl':['Probability distribution $P(k_{in})$'], '-axisfsize':['large'], '-ncol':[1], '-loc':[1]}) for i in range(len(lsarg)): ds = [] func = lsarg[i]['func'][0] step = p.STEP argstep = getargval(lsarg[i], '-j') if argstep: step = int(argstep[0]) f = open(lsarg[i]['files'][0]) try: data = json.load(f) p.loaddata(ds, func, data, lsarg[i]['files'][0], step) finally: f.close() logx = False arglogx = getargval(lsarg[i], '-logx') if arglogx: logx = int(arglogx[0]) > 0 logy = False arglogy = getargval(lsarg[i], '-logy') if arglogy: logy = int(arglogy[0]) > 0 lb = p.LOGBINBASE arglb = getargval(lsarg[i], '-lb') if arglb: lb = float(arglb[0]) xlim = getargval(lsarg[i], '-xlim') ylim = getargval(lsarg[i], '-ylim') plotfile = getargval(lsarg[i], '-v', [None])[0] if func in [p.FUNC_LOGINDEG, p.FUNC_HISTINDEG]: xlabel = 'In-degree' elif func in [p.FUNC_LOGOUTDEG, p.FUNC_HISTOUTDEG]: xlabel = 'Out-degree' axisfsize = getargval(lsarg[i], '-axisfsize', ['medium'])[0] try: axisfsize = int(axisfsize) except: pass ncol = int(getargval(lsarg[i], '-ncol', [1])[0]) numpoints = int(getargval(lsarg[i], '-numpoints', [1])[0]) if func in [p.FUNC_LOGINDEG, p.FUNC_LOGOUTDEG]: # loglog degree distribution p.drawloglogdist(ds , xlabel=getargval(lsarg[i], '-xl', [''])[0] , ylabel=getargval(lsarg[i], '-yl', [''])[0] , title=getargval(lsarg[i], '-t', [''])[0] , labels=getargval(lsarg[i], '-l') , markset=getargval(lsarg[i], '-m', ['var'])[0] , xlim=xlim , ylim=ylim , axisfsize=axisfsize , logbinbase=lb , showexp=int(getargval(lsarg[i], '-g', [1])[0]) , legloc=int(getargval(lsarg[i], '-loc', [1])[0]) , ax=p.plt.gca() , ncol=ncol , numpoints=numpoints) elif func in [p.FUNC_DISTINDEG, p.FUNC_DISTOUTDEG]: # degree distribution plot if p.FUNC_DISTINDEG: title = getargval(lsarg[i], '-t', ['Degree distribution of exponential network'])[0] xylabels = {'x':getargval(lsarg[i], '-xl', ['k (degree)'])[0], 'y':getargval(lsarg[i], '-yl', ['P(k)'])[0]} else: title = getargval(lsarg[i], '-t', ['Outdegree distribution'])[0] xylabels = {'x':getargval(lsarg[i], '-xl', ['Outdegree'])[0], 'y':getargval(lsarg[i], '-yl', ['Number of nodes'])[0]} p.plotdegdist(ds , getargval(lsarg[i], '-l') , getargval(lsarg[i], '-m', ['var'])[0] , title=title , xylabels=xylabels , nbins=int(getargval(lsarg[i], '-b', ['50'])[0]) , logx=logx, logy=logy , xlim=xlim , ylim=ylim , axisfsize=axisfsize , legloc=int(getargval(lsarg[i], '-loc', [1])[0]) , ax=p.plt.gca() , ncol=ncol , numpoints=numpoints) p.processplot(p.plt, getargval(lsarg[i], '-s', [None])[0])
def main(argv): lsarg = [] lsarg.append( { "func": ["-li"], "files": ["simdata/svcsimn_10k_10k_d2_a7_i10_avg1_8.json"], "-m": ["reddia"], "-l": ["scale-free"], "-g": [0], "-lb": ["1.21"], "-gl": [0], } ) lsarg.append( { "func": ["-di"], "files": ["simdata/expsvcsimn_10k_10k_d2_a7_i10_avg1_8.json"], "-m": ["bluepenta"], "-b": ["100"], "-l": ["exponential"], } ) lsarg.append( { "func": ["-di"], "files": ["simdata/randsvcsimn_10k_10k_d2_a11_i10_avg1_8.json"], "-m": ["trihexaorg"], "-b": ["100"], "-l": ["random"], "-logx": [1], "-logy": [1], "-xlim": [1, 500], "-ylim": [1e-6, 1], "-t": ["Scale-free, exponential, and random network degree distribution"], "-xl": ["In-degree $k_{in}$"], "-yl": ["Probability distribution $P(k_{in})$"], "-axisfsize": ["large"], "-ncol": [1], "-loc": [1], } ) for i in range(len(lsarg)): ds = [] func = lsarg[i]["func"][0] step = p.STEP argstep = getargval(lsarg[i], "-j") if argstep: step = int(argstep[0]) f = open(lsarg[i]["files"][0]) try: data = json.load(f) p.loaddata(ds, func, data, lsarg[i]["files"][0], step) finally: f.close() logx = False arglogx = getargval(lsarg[i], "-logx") if arglogx: logx = int(arglogx[0]) > 0 logy = False arglogy = getargval(lsarg[i], "-logy") if arglogy: logy = int(arglogy[0]) > 0 lb = p.LOGBINBASE arglb = getargval(lsarg[i], "-lb") if arglb: lb = float(arglb[0]) xlim = getargval(lsarg[i], "-xlim") ylim = getargval(lsarg[i], "-ylim") plotfile = getargval(lsarg[i], "-v", [None])[0] if func in [p.FUNC_LOGINDEG, p.FUNC_HISTINDEG]: xlabel = "In-degree" elif func in [p.FUNC_LOGOUTDEG, p.FUNC_HISTOUTDEG]: xlabel = "Out-degree" axisfsize = getargval(lsarg[i], "-axisfsize", ["medium"])[0] try: axisfsize = int(axisfsize) except: pass ncol = int(getargval(lsarg[i], "-ncol", [1])[0]) numpoints = int(getargval(lsarg[i], "-numpoints", [1])[0]) if func in [p.FUNC_LOGINDEG, p.FUNC_LOGOUTDEG]: # loglog degree distribution p.drawloglogdist( ds, xlabel=getargval(lsarg[i], "-xl", [""])[0], ylabel=getargval(lsarg[i], "-yl", [""])[0], title=getargval(lsarg[i], "-t", [""])[0], labels=getargval(lsarg[i], "-l"), markset=getargval(lsarg[i], "-m", ["var"])[0], xlim=xlim, ylim=ylim, axisfsize=axisfsize, logbinbase=lb, showexp=int(getargval(lsarg[i], "-g", [1])[0]), legloc=int(getargval(lsarg[i], "-loc", [1])[0]), ax=p.plt.gca(), ncol=ncol, numpoints=numpoints, isexpline=int(getargval(lsarg[i], "-gl", [1])[0]), ) elif func in [p.FUNC_DISTINDEG, p.FUNC_DISTOUTDEG]: # degree distribution plot if p.FUNC_DISTINDEG: title = getargval(lsarg[i], "-t", ["Degree distribution of exponential network"])[0] xylabels = { "x": getargval(lsarg[i], "-xl", ["k (degree)"])[0], "y": getargval(lsarg[i], "-yl", ["P(k)"])[0], } else: title = getargval(lsarg[i], "-t", ["Outdegree distribution"])[0] xylabels = { "x": getargval(lsarg[i], "-xl", ["Outdegree"])[0], "y": getargval(lsarg[i], "-yl", ["Number of nodes"])[0], } p.plotdegdist( ds, getargval(lsarg[i], "-l"), getargval(lsarg[i], "-m", ["var"])[0], title=title, xylabels=xylabels, nbins=int(getargval(lsarg[i], "-b", ["50"])[0]), logx=logx, logy=logy, xlim=xlim, ylim=ylim, axisfsize=axisfsize, legloc=int(getargval(lsarg[i], "-loc", [1])[0]), ax=p.plt.gca(), ncol=ncol, numpoints=numpoints, ) p.processplot(p.plt, getargval(lsarg[i], "-s", [None])[0])