Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a Marker To Ndlib Graph Viz #122

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added b1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added b2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added b3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added b4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fs1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 16 additions & 14 deletions ndlib/viz/mpl/ComparisonViz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand All @@ -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
Expand Down Expand Up @@ -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))

Expand Down
16 changes: 8 additions & 8 deletions ndlib/viz/mpl/DiffusionViz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
Binary file added sc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sc1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.