diff --git a/b1.png b/b1.png new file mode 100644 index 0000000..5c0e7af Binary files /dev/null and b/b1.png differ diff --git a/b2.png b/b2.png new file mode 100644 index 0000000..f90e54f Binary files /dev/null and b/b2.png differ diff --git a/b3.png b/b3.png new file mode 100644 index 0000000..e80cc91 Binary files /dev/null and b/b3.png differ diff --git a/b4.png b/b4.png new file mode 100644 index 0000000..3301580 Binary files /dev/null and b/b4.png differ diff --git a/fs.png b/fs.png new file mode 100644 index 0000000..7e8452e Binary files /dev/null and b/fs.png differ diff --git a/fs1.png b/fs1.png new file mode 100644 index 0000000..ab9a910 Binary files /dev/null and b/fs1.png differ diff --git a/ndlib/viz/mpl/ComparisonViz.py b/ndlib/viz/mpl/ComparisonViz.py index a65655c..6dff6c9 100644 --- a/ndlib/viz/mpl/ComparisonViz.py +++ b/ndlib/viz/mpl/ComparisonViz.py @@ -9,12 +9,12 @@ import future.utils import past import six - +import itertools __author__ = 'Giulio Rossetti' __license__ = "BSD-2-Clause" __email__ = "giulio.rossetti@gmail.com" - +marker = itertools.cycle(('D', '+', '>', 'o', '*')) class InitializationException(Exception): """Initialization Exception""" @@ -38,7 +38,7 @@ def __init__(self, models, trends, statuses=["Infected"]): for model in models: srev = {v: k for k, v in future.utils.iteritems(sts[i])} self.nnodes = model.graph.number_of_nodes() - for cl in srev.values(): + for cl in list(srev.values()): available_classes[cl] = None self.srev["%s_%s" % (model.name, i)] = srev @@ -76,32 +76,34 @@ def plot(self, filename=None, percentile=90): :param percentile: The percentile for the trend variance area. Default 90. """ - + pres = self.iteration_series(percentile) - + mx = 0 i, h = 0, 0 for k, l in future.utils.iteritems(pres): + j = 0 for st in l: + mx = len(l[st][0]) if self.normalized: - plt.plot(range(0, mx), l[st][1]/self.nnodes, lw=2, - label="%s - %s" % (k.split("_")[0], st), alpha=0.9, color=cols[h+j]) - plt.fill_between(range(0, mx), l[st][0]/self.nnodes, - l[st][2]/self.nnodes, alpha=0.2, color=cols[h+j]) + plt.plot(list(range(0, mx)), l[st][1]/self.nnodes, lw=2, + label="%s - %s" % (k.split("_")[0], st), alpha=0.9, marker = next(marker), color=cols[h+j]) + plt.fill_between(list(range(0, mx)), l[st][0]/self.nnodes, + l[st][2]/self.nnodes,alpha=0.2, color=cols[h+j]) else: - plt.plot(range(0, mx), l[st][1], lw=2, - label="%s - %s" % (k.split("_")[0], st), alpha=0.9, color=cols[h + j]) - plt.fill_between(range(0, mx), l[st][0], + plt.plot(list(range(0, mx)), l[st][1], lw=2, + label="%s - %s" % (k.split("_")[0], st),alpha=0.9, marker = next(marker), color=cols[h + j]) + plt.fill_between(list(range(0, mx)), l[st][0], l[st][2], alpha=0.2, color=cols[h + j]) j += 1 i += 1 h += 2 plt.grid(axis="y") - plt.xlabel("Iterations", fontsize=24) - plt.ylabel(self.ylabel, fontsize=24) + plt.xlabel("Iterations", fontsize=20) + plt.ylabel(self.ylabel, fontsize=20) plt.legend(loc="best", fontsize=18) plt.xlim((0, mx)) diff --git a/ndlib/viz/mpl/DiffusionViz.py b/ndlib/viz/mpl/DiffusionViz.py index 754f8ac..ab7dd9c 100644 --- a/ndlib/viz/mpl/DiffusionViz.py +++ b/ndlib/viz/mpl/DiffusionViz.py @@ -8,12 +8,12 @@ import matplotlib.pyplot as plt import future.utils import six - +import itertools __author__ = 'Giulio Rossetti' __license__ = "BSD-2-Clause" __email__ = "giulio.rossetti@gmail.com" - +marker = itertools.cycle(('D', '+', '>', 'o', '*')) @six.add_metaclass(abc.ABCMeta) class DiffusionPlot(object): # __metaclass__ = abc.ABCMeta @@ -65,13 +65,13 @@ def plot(self, filename=None, percentile=90, statuses=None): continue mx = len(l[0]) if self.normalized: - plt.plot(range(0, mx), l[1]/self.nnodes, lw=2, label=self.srev[k], alpha=0.5) # , color=cols[i]) - plt.fill_between(range(0, mx), l[0]/self.nnodes, l[2]/self.nnodes, alpha=0.2) - #,color=cols[i]) + plt.plot(list(range(0, mx)), l[1]/self.nnodes, lw=2, label=self.srev[k], alpha=0.5, marker = next(marker),markersize=12, color=cols[i]) + plt.fill_between(list(range(0, mx)), l[0]/self.nnodes, l[2]/self.nnodes, alpha="0.2", + color=cols[i]) else: - plt.plot(range(0, mx), l[1], lw=2, label=self.srev[k], alpha=0.5) # , color=cols[i]) - plt.fill_between(range(0, mx), l[0], l[2], alpha=0.2) # ,color=cols[i]) - + plt.plot(list(range(0, mx)), l[1], lw=2, label=self.srev[k], alpha=0.5, marker = next(marker),markersize=12, color=cols[i]) + plt.fill_between(list(range(0, mx)), l[0], l[2], alpha="0.2", + color=cols[i]) i += 1 plt.grid(axis="y") diff --git a/sc.png b/sc.png new file mode 100644 index 0000000..5dfd02b Binary files /dev/null and b/sc.png differ diff --git a/sc1.png b/sc1.png new file mode 100644 index 0000000..fecba2c Binary files /dev/null and b/sc1.png differ