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

Conversation

amshoo
Copy link

@amshoo amshoo commented Jul 15, 2019

Ndlib_Marker_Viz

Adding a Marker To Ndlib Graph Viz

Adding marker to Ndlib ComparisonViz and DiffusionViz to distinguish multiple lines and improve visual understanding.

NDlib is a Python software package that allows to describe, simulate, and study diffusion processes on complex networks. The package was design and documentation by Giulia Rossetti you can find examples, tutorials and a complete reference here ndlib.

Matplotlib Marker: a basic matplotlib Marker plot, this shows a few optional features, like defining legend labels, legend size, and maker size.

#Code to plot a simple demo with a “*” marker.
 
import matplotlib.pyplot as plt
x = [1,2,3,4,5]
fig, ax = plt.subplots()
ax.plot(x, '*' , markersize=12, label='(*)')
ax.axis('equal')
leg = ax.legend(fontsize=12);

Below are some basic example plots for markers (‘*’, ‘o’ , ’v’ , ‘+’) respectively.

graph1
graph2
graph3
graph4

Assign a unique marker for each plot

Form Solution 4in StackOverflow, which answer the question of how to us unique markers for each plot in matplotlib. the solution uses ‘itertools.cycle’ to iterate over a list or tuple indefinitely which picks markers randomly for you. The answer below.

Python 2.x

import itertools
marker = itertools.cycle((',', '+', '.', 'o', '*')) for n in y:
    plt.plot(x,n, marker = marker.next(), linestyle='')

Python 3.x

import itertools
marker = itertools.cycle((',', '+', '.', 'o', '*')) for n in y:
plt.plot(x,n, marker = next(marker), linestyle='')

To find the set of All possible markers you can visit matplotlib.markers[2] in matplotlib website (https://matplotlib.org/3.1.0/api/markers_api.html).

Ndlib Graph Viz

From the documentation of Ndlib, it shown that the model uses matplotlib and bakeh to visualize the diffusion/spreading process and did a good job but Adding markers to a line can be a useful way to distinguish multiple lines or to highlight particular data points. So above solution to add unique markers to all lines.
Instead of visualizing the diffusion process like this:

graph
graph

It can be visualize like this:

graph
graph

@coveralls
Copy link

coveralls commented Jul 15, 2019

Coverage Status

Coverage decreased (-0.05%) to 94.578% when pulling 1c843ba on amshoo:master into 1927b58 on GiulioRossetti:master.

@Bisma1
Copy link

Bisma1 commented Jul 9, 2022

I agree, this is very helpful in distinguishing the plots but I need to specifically replace legend names to depict the name of dataset or method. Is there any way out to alter those as I am naïve to viz plots . thankyou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants