Option to save the edited Pyvis network html graph file - python

I am using Python module pyvis to plot a network graph. Like manytimes, the initial graph is cluttered for the nodes, so i do the node moves to make it clean and better. After that i save the HTML file. When i reopen the HTML file again, the node positions which i changed for a better and clean look is reset and back to same random plotting.
Is there a way i can lock the network plot after improving the node layout and positions ? is there a way we can force the java script to save also the node/edge locations,colors,lengths and reuse on next open of the graph?
Where is the information about node positions stored for HTML graph? is it something computed dynamically during the java script run when HTML file is opened?

From the docs, you can look at this small gif:
[animated gif](https://pyvis.readthedocs.io/en/latest/_images/set_options_ex.gif)
Basically:
Once you have configured all the parameters in your graph trough the buttons:
g.show_buttons()
You can copy & paste those options inside 'set_options':
g.set_options("""
pasted_options_copied_from_generate_options_button
""")
And before run it again, comment the 'show_buttons()':
# g.show_buttons()

Related

Exporting functional Plotly sunburst plot

Does anyone know how I can export a plotly sunburst plot as a standalone file which can keep all the functionalities, like annotation while hovering and expansion by click?
Visualizing a hierarchical data with plotly.sunburst in python is a beautiful and beneficial way of presenting it in the best order, while you are able to hover the values to see the annotation, click on each parent section to collapse and expand the child values, etc.. But to present the visualized data (plot) independently without having to open the Python notebook, needs the plot to be saved and exported in a standalone file format that allows keeping every functionality available.
Does anyone know how to do this? and what file format can give this luxury to us?
Thanks
Saving to an HTML file will do the trick:
doc

Recreating Process Flow in Python NetworkX

Would anyone know how to recreate this flow chart in networkx? I know I can manually add these nodes and add the edges, but I wanted to write some code that could be applicable for other data types like CSV or EXCEl.
My main idea was to convert this flow into Excel and then have the program read that file and create nodes and edge.
I do have something that is able to read the file and then create nodes using that file. However, I cannot get the edges and the specificities of the flow correct in network.
If anyone could help that would be great. Thanks
This is the flow I wish to recreate
I would try loading the csv into a pandas dataframe. Networkx can be very finicky on how the incoming data needs to be formatted. So I would import it to the dataframe the have networkx read it out of there.

How to export plotly plots, tabs and images into a single html

I would like to know if there is a way to export multiple plotly plots, tabs and images into a single HTML file.
In detail the problem is this. I want to create a standalone .exe file with python able to plot several graphs and images, given some input files containing the data; writing code with PySimpleGUI for the GUI.
But once the several interactive graphs, tabs and images are plotted in a window, I would like to add in the window two buttons to export these data respectively in a excel file (so with no interactivity) and in a HTML file (to keep interactivity).
The first point is no trouble for me: I use xlsxwriter to export images and graphs as images. The problem is the second point: I would like to export all these data keeping interactions in graphs in a single HTML with a certain design I choose. Remember the fact that I want to build a standalone .exe file, because this program will run in a PC with Python not installed.
My question is this: is there some python library or html writer in python I can use to do this?
P.S.: plotly graphs are not subplots of a single plots but each one is a single plot, each one will have its own zoom etc. commands.

How do I set a name_scope in a graph to be removed from main graph in python

I'm trying to organize my TensorBoard graph such that a certain component is automatically placed on the side when I first initiate TensorBoard.
I want the save node to be on the right, like this:
I can right click on save in the graph itself, But I'd rather have it waiting for me this way when I get there.
This isn't currently possible, although we are planning to do this as part of a broader push to improve the graph visualizer in the next few months.
If you want, you can file a GitHub issue for tracking (but we will do this either way).

How to visualize a graph using d3.js in iPython notebook?

I have a graph that I would like to visualize using d3.js. Specifically, I have an adjacency matrix that looks as follows (selection of data, not the full set):
Node 1 Node 2 Weight
A B 1.0
A C 1.0
A D 1.5
B D 1.0
...
I would like to be able to use a Force-Directed Graph to display my network, specifically.
I know how to create a NetworkX graph, but I would like to be able to try this in d3.js, as I want to be able to add mouseover displays of node properties later on, which I think is possible using d3 but not possible using matplotlib.
I have tried using d3py, but I can't even get the basic example to work, and I read that the NetworkX example is broken and the repo hasn't been updated for a while. Does anybody else know if there's something else I could try, or if someone could point me in a first step direction?
There is a NetworkX example here that uses d3.js force layout :http://networkx.github.io/documentation/latest/examples/javascript/force.html
It just writes a JSON format graph object from networkx that d3.js can load in a web browser to get an interactive drawing. That code is a little fancier since it will also do the web browser part for you.
All of the code (including the d3 parts) you need to run it are in the repository https://github.com/networkx/networkx/tree/master/examples/javascript
If you're fine with an alternative JavaScript framework, we've been building http://www.github.com/graphistry/pygraphistry . The idea is to use WebGL to render the big graphs (pan/zoom/etc.), and offload most of the real-time compute (layout, filter, etc.) to a GPU cloud. There's an API underneath for controlling it similarly to D3. It's easier for most uses however, as it streamlines common big graph manipulations and analyses.

Categories