{ "info": { "author": "Tahsin Mayeesha", "author_email": "tasmiah.tahsin@hotmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Science/Research", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Scientific/Engineering :: Mathematics" ], "description": "![](readmegif.gif)\n\n# Mediaviz\n\nMediaviz is a network visualization library created for my project [Automating Network Visualization and community detection of Media Sources Network from Mediacloud data](https://summerofcode.withgoogle.com/projects/#6265196406898688) done with [Berkman Klein Center of Internet And Society](http://cyber.law.harvard.edu/) at Harvard University while participating at [Google Summer Of Code 2018](https://summerofcode.withgoogle.com/) under the guidance of mentor [Hal Roberts](http://cyber.harvard.edu/people/hroberts).\n\n[Mediacloud](http://mediacloud.org/) is an open source, open data platform for researchers that provides data and statistics for quantitative analysis. Mediaviz has been originally developed to automate the network visualization of the media source networks for different topics such as network neutrality, ebola and more. \n\nHowever, beyond the mediacloud usage, Mediaviz is also a general purpose network visualization library provides functionalities for force based layout such as [force atlas 2](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0098679), automatic scaling to prevent node overlap, Gephi like features for network filtering, coloring, node resizing, prevention of label overlap and community visualization. \n\nMediaviz uses force atlas 2 layout as default and scales the layout automatically for graphs with 100-1000 nodes that has a power law linking structure. Having sensible defaults, Mediaviz can be used for general graph visualization as well as publishable graphs with many customization parameters including using the drawing function with any other network layout function in networkx or beyond. \n\nExamples and demo visualizations are provided in the usage section.\n\n# Documentation\n\nComplete Documentation is available at https://mediaviz.readthedocs.io/en/latest/ \n\n\n\n![](assets/deep_state.png)\n\n\n\n\n\n\n\n\n\n\n\n# Installation\n\nTo install the package from pip :\n\n```python\npip install mediaviz\n```\n\nTo build from source , download the repository and go to the Mediaviz top level directory. Then use\n\n```python\npython setup.py install \n```\n\nor \n\n```python\npip install .\n```\n\n\n\n# Dependencies \n\n* [networkx](https://networkx.github.io)\n* [fa2l](https://github.com/bosiakov/fa2l/tree/master/fa2l)\n* [adjusttext](http://adjusttext.readthedocs.io)\n* [matplotlib](https://matplotlib.org)\n* [numpy](http://www.numpy.org/)\n* [python-louvain](https://python-louvain.readthedocs.io/en/latest/)\n\n\n\n# Blog Posts\n\n- [GSOC 2018 Experience : Visualizing Media Data With Network Analysis (PART 1 )](https://medium.com/learning-machine-learning/gsoc-2018-experience-visualizing-media-data-with-network-analysis-part-1-c4ba4b76b1aa)\n- [GSOC 2018 : Network Visualization Of MediaCloud Topic Network + 1st evaluation (Part 2)](https://medium.com/learning-machine-learning/gsoc-2018-network-visualization-of-mediacloud-topic-network-1st-evaluation-part-2-ca72e25a88d5)\n\n\n# Usage\n\n#### Draw a Network with Force Atlas 2 Layout With Default Parameters\n\n```python\nimport networkx as nx\nfrom mediaviz.draw import draw_forceatlas2_network\n\npath= 'graphname.gexf'\nG = nx.erdos_renyi_graph(200,0.7)\n\ndraw_forceatlas2_network(G,node_color='purple', node_size=10, edge_color='gray',filename=\"random.png\")\n```\n\n![](assets/random.png)\n\n#### Drawing Network with Force Atlas 2 Layout with customization\n\nHere we parse color codes from .gexf visual attributes.\n\n```python\nimport networkx as nx\nfrom mediaviz.draw import draw_forceatlas2_network\nfrom mediaviz.viz_parser import parse_colors, parse_size\n\n# 1000 node graph from mediacloud on network neutrality topic\npath = \"network_neutrality.gexf\" \nG = nx.read_gexf(path)\nnode_colors = list(parse_colors(path,hex=True).values())\ndraw_forceatlas2_network(G,\n num_labels = 30, # num_labels indicates to only label top 30 largest nodes by node_size\n fa2l_scaling_ratio=40,fa2l_iterations=100, # parameters for the force atlas 2 layout\n node_color = node_colors, \n with_labels=True, label_field=\"label\",\n filter_by=\"inlink_count\", top=200, # filter to get top 200 nodes sorted by inlink_count\n size_field = \"inlink_count\",min_size=0.1,max_size=200, # resize by inlink_count\n adjust_labels=True, # adjusts labels to prevent label overlap\n node_opacity=0.8, edge_opacity=0.01, \n font_size=6, # size of label font_size \n filename= \"network_neutrality.png\", title=\"network_neutrality\",\n edge_color_by_source=True)\n```\n\n![](assets/network_neutrality.png)\n\n\n\n#### Drawing Network With Community Detection and Coloring By Community Partitions\n\n```python\nimport community\nimport networkx as nx\nfrom mediaviz.community_utils import get_community_graph, get_community_colormap\nfrom mediaviz.draw import draw_forceatlas2_network\n\nG = nx.florentine_families_graph() \n# get the community partitions and set partition as an attribute for the nodes \nG, partitions = get_community_graph(G) \n# colormaps are automatically assigned for each partition as randomly genererated hex colors\ncolormap = get_community_colormap(partitions)\n# use the draw function as usual with forceatlas2 layout as default\ndraw_forceatlas2_network(\n G,\n color_by=\"partition\", colormap=colormap,\n node_size = 10,\n with_labels=True, \n edge_color_by_source=True, node_opacity = 1, edge_opacity = 1,\n font_size=10, filename = \"community.png\",\n figsize=(10, 10));\n```\n\n![ ](assets/community.png)\n\n#### Only Using Draw Function for Customized Visualization With Other Layout Algorithms\n\n```python\nimport networkx as nx\nfrom mediaviz.draw import draw_forceatlas2_network\nG = nx.karate_club_graph()\npos = nx.spring_layout(G)\ndraw_forceatlas2_network(G,\n pos = pos,\n node_size=10,\n color_by=\"club\",\n colormap={\"Officer\":\"r\",\"Mr. Hi\":\"b\"},\n node_opacity=1,edge_opacity=1, filename=\"karate_club.png\",\n edge_color=\"lightgray\")\n```\n\n![](assets/karate_club.png)\n\n\n\n# Contribution and Further Improvement\n\nIf you want to contribute please send a pull request with listing the changes you have made and the reasoning clearly stated. Integrating the drawing function with matplotlib better and trying out different heuristics for automated scaling would be a priority.\n\n# License\n\nThis project is licensed under the MIT License - see the License.txt file for details.\n\n\n\n\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Tahsin-Mayeesha/Mediaviz", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "mediaviz", "package_url": "https://pypi.org/project/mediaviz/", "platform": "", "project_url": "https://pypi.org/project/mediaviz/", "project_urls": { "Homepage": "https://github.com/Tahsin-Mayeesha/Mediaviz" }, "release_url": "https://pypi.org/project/mediaviz/0.1.2/", "requires_dist": [ "fa2l", "networkx (<2.0.0)", "numpy", "matplotlib", "python-louvain", "adjustText" ], "requires_python": "", "summary": "Visualize Networks With Force Atlas 2 Layout", "version": "0.1.2" }, "last_serial": 4161313, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "c96613f6436352af9ee9b350130411b3", "sha256": "fe842348ea469b2077ccc72e673c9f477ecfeb5302d0aa2a615174423a0f1ca1" }, "downloads": -1, "filename": "mediaviz-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c96613f6436352af9ee9b350130411b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14552, "upload_time": "2018-08-12T09:51:09", "url": "https://files.pythonhosted.org/packages/a5/60/9e4c7db0e727c697f899469b46ea0f197385c5196f31805967ebab4ce609/mediaviz-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "420167f630271538f09de4c39063f5db", "sha256": "5132acf58ebacc66571928b3e46a6a604db1841de2e8521732349a24176b2ad1" }, "downloads": -1, "filename": "mediaviz-0.1.1.tar.gz", "has_sig": false, "md5_digest": "420167f630271538f09de4c39063f5db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12729, "upload_time": "2018-08-12T09:51:10", "url": "https://files.pythonhosted.org/packages/96/96/7011d63c8611b2b81c0d7e98e270c279ea4795201154eb90613a87628f58/mediaviz-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "b904c7b5185141ef03f79ed52077604f", "sha256": "ea75098f34e676ea89628ed6cf38b540cc0ba5210ec0957ca75132bda36a1baf" }, "downloads": -1, "filename": "mediaviz-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b904c7b5185141ef03f79ed52077604f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14553, "upload_time": "2018-08-12T09:57:57", "url": "https://files.pythonhosted.org/packages/5b/81/f47f08c100aeee149eba3efee306b750c5530b4e41e4dd7904783e4fe0c2/mediaviz-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f9946763c776d0f1b1981841921d54b6", "sha256": "3c34a21648bafc7550fbc448644dc90da8aec6d8b786167c29cf7207ac469703" }, "downloads": -1, "filename": "mediaviz-0.1.2.tar.gz", "has_sig": false, "md5_digest": "f9946763c776d0f1b1981841921d54b6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12723, "upload_time": "2018-08-12T09:57:58", "url": "https://files.pythonhosted.org/packages/1d/e1/73faec80caa9f8026ae048ddd0f5ca1ed7c6877e90104bfa786605cea080/mediaviz-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b904c7b5185141ef03f79ed52077604f", "sha256": "ea75098f34e676ea89628ed6cf38b540cc0ba5210ec0957ca75132bda36a1baf" }, "downloads": -1, "filename": "mediaviz-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "b904c7b5185141ef03f79ed52077604f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14553, "upload_time": "2018-08-12T09:57:57", "url": "https://files.pythonhosted.org/packages/5b/81/f47f08c100aeee149eba3efee306b750c5530b4e41e4dd7904783e4fe0c2/mediaviz-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f9946763c776d0f1b1981841921d54b6", "sha256": "3c34a21648bafc7550fbc448644dc90da8aec6d8b786167c29cf7207ac469703" }, "downloads": -1, "filename": "mediaviz-0.1.2.tar.gz", "has_sig": false, "md5_digest": "f9946763c776d0f1b1981841921d54b6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12723, "upload_time": "2018-08-12T09:57:58", "url": "https://files.pythonhosted.org/packages/1d/e1/73faec80caa9f8026ae048ddd0f5ca1ed7c6877e90104bfa786605cea080/mediaviz-0.1.2.tar.gz" } ] }