在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:intuitivetextmining/d3fdgraph开源软件地址:https://github.com/intuitivetextmining/d3fdgraph开源编程语言:Python 86.0%开源软件介绍:d3fdgraphPlots an interactive force directed graph in a jupyter notebook, taking data from a dataframe of nodes and link weights. Why d3fdgraph?Working with data using python in the jupyter notebook provides many options for visualising that data. The pandas library provides convenient common visualisations, and there's always the venerable matplotlib for more bespoke plots. The new vega-lite library is enabled by default in jupyterlab. Sometimes we want to plot the relationships between things as a graph of linked nodes. The networkx library can plot graphs in a notebook but the plots are static, and only really suitable for smaller data. Being able to interactively adjust graphs really helps explore larger data. That's what d3fdgraph does. Installing d3fdgraphInstalling d3fdgraph is easy. pip install d3fdgraph This has been tested with Anaconda Python 3. How To UseTo use d3fdgraph in a notebook we import the library. import d3fdgraph d3fdgraph takes data in the form of a pandas dataframe. That dataframe must have 3 columns:
The larger the weight, the more strongly related the two nodes at each end of this link. Here is an example dataframe:
Each row is a link:
The column names don't have to be The order of the 3 columns is what matters. d3fdgraph will use the first column as the source nodes, the second as the target, and the third as link weights. To draw an interactive force directed graph of these nodes and links we simply pass this dataframe to the plot_force_directed_graph() function. d3fdgraph.plot_force_directed_graph(dataframe) Here is an example of a graph made from different data. The nodes are labelled with the names of the nodes, as described in the pandas dataframe. The nodes are constrained from flying off the edge of the canvas. InteractivityYou can use your pointer to drag nodes around to adjust the graph. Double-clicking a node makes it jump to the centre of the canvas, from where it might depart slightly due to the simulated forces. Additional Parametersplot_force_directed_graph(node1_node1_weight, node_radius=3, link_distance=20, collision_scale=4) You don't have to use the additional parameters, but they might help improve the readability of your graph.
Example NotebookA simple jupyter notebook showing how d3fdgraph can be used is here: NoteNote that d3fdgraph is only useful in a jupyter notebook. It isn't useful in a terminal, and hasn't been tested in other kinds of python notebook. d3graph has been tested to work in the Anaconda Python's jupyter notebook, and also the mybinder instances too. Recently it has been made to work in Google's Colab notebook environment. JupyterLab is moving away from allowing javascript in notebook cells, and encouraging develpment of extensions insted. Since JupyterLab is not ready for production, and not widely adopted yet, the focus here is on Jupyter and Colab notebooks. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论