I am trying to visualize a Control Flow Graph in Python using pyqtgraph. I have the following two problems.
How can I visualize the edges with a direction?
How can I visualize a self edge?
I tried looking into the documentation, but couldn't find. Obviously, I didn't get time to read it all!
While pyqtgraph is awesome, for my use case I found a much better tool to do this.
graphviz is a nice tool to develop Control Flow Graphs quite conveniently, and has a large number of features for this particular problem.
For direction, you might add a pg.ArrowItem at the end of each line (although this could have poor performance for large networks), and for self connections, QtGui.QGraphicsEllipseItem combined with an arrow.
Related
I am working in a project where 3D visualizations are important to see what is happening during the setup stage and perhaps for visual validation by making a short videos of what is happening.
The problem that I have is that 3D visualizations in Python are too sophisticated, and complicated to learn for what I need. I find that Mathematica is the perfect kind of software...but it is not portable and is very expensive.
Question
Is there any Python package similar to Mathematica?
Clarification
I don't want a "plotting" program, since plotting is not what I am looking for. I want to generate simple geometric shapes like spheres and cubes that can move around, this is more than enough. Give some coordinates, perhaps a rotation, and the program just shows the desired image(s) to export as a .png or make a quick video; as in Mathematica.
Packages like Pygame, Panda3D, Pyglet, etc., look too complicated and an overkill for what I need, as well as software like Blender, etc. Jupyter notebooks are similar, but they don't have the 3D graphics capabilities. I found a Python module named Fresnel, but it looks too sophisticated for what I need.
I have read several answers to this question here in Stack Overflow, but they seem outdated and not really what I am looking for.
Further Clarification
To draw spheres in Mathematica you do:
coordinates = Flatten[Table[Table[Table[ {i,j,k}, {k,1,10}], {j,1,10}], {i,1,10}],1]
spheres= Flatten[Table[Graphics3D[{Sphere[coordinates[[i]],0.5]}],{i,1,Length[coordinates]}]]
Show[{spheres}]
This is a simple quick and easy way of displaying a group of spheres. To use any program in Python to do the same, it seems like you must be an expert in 3D graphics to do this simple thing.
Programs that have capabilities of using Python scripts, like Blender, make it difficult to use the interface in a straight forward way (try doing the same in Blender, it will take a while just to learn the basics!).
I know several other user-friendly plotting libraries than matplotlib, but not a lot provide an interactive view. There is of course the well known vtk but it's not for end-user
plotly
For usage in a notebook, like jupyter and mathematica, you probably would go for plotly It's using a browser-based interface with plots very similar to mathematica
pymadcad
If you need a more offline version and what you are looking for is some view you can rotate/zoom/pan to look on your geometry by different sides, you can take a look at pymadcad
It even works with touchscreens.
It is not centered on 3D visualization, so it's a bit overkill to use it only for it, but for 3D curves, 3D surfaces, spheres and cubes as you said, it can do the job
simple plots with pymadcad:
from madcad import *
from madcad.rendering import Displayable
from madcad.displays import GridDisplay
# create a wire from custom points
s = 100
mycurve = Wire([ vec3(sin(t/s), cos(t/s), 0.1*t/s)
for t in range(int(s*6*pi)) ])
# create a sphere
mysphere = uvsphere(vec3(0), 0.5)
# display in a separated window
show([
mycurve, # displaying the curve
mysphere, # displaying the sphere
Displayable(GridDisplay, vec3(0)), # this is to have a 2D grid centered on origin
])
result:
(The window is dark because so is my system theme, but likely it will adapt to yours)
I Have a Huge data-set with more than million nodes, edges and communities. What is the best way to plot a network graph that shows clusters.
I did try Cytoscape using but that does not seem to provide what I am looking for.
I am trying to find a better way may be programming in Python to plot a cluster graph.
Any suggestions are appreciated... Thanks in advance
You flagged your post with networkx. Did you try the in-built drawing functions with Matplotlib? See the documentation here. However, even there they strongly recommend specialized software such as Cytoscape, Gephi or Graphviz.
I am trying to implement Alec Radford's visualizations of gradient descents in Python with matplotlib animation. I have found this question, which is a good start and I have been playing around a bit with the code.
However I am wondering how to animate persistent lines.
(For example the ones that show the different path taken by the algorithm for different gradient descent in Alec's visualizations).
Maybe a link to the code Alec used is available it certainly looks like it was also done in matplotlib...
I already have a way of clustering my graph, so the process of clustering isn't the issue here. What I want to do is, once we have all the nodes clustered - to draw the clustered graph in Python, something like this:
I looked into networkx, igraph and graph-tool, but they seem to do the clustering, but not the drawing. Any ideas and propositions of what library should I use for drawing the already clustered graph, which will minimize the number of crossing links?
Take a look at GraphViz
http://www.graphviz.org/Gallery/directed/cluster.html
There's a Python binding for that, but I have to say I always create the text files directly as they're easy enough to write. Don't be fooled by the plain-looking examples, every aspect of your graph is highly customizable and you can make some pretty nifty graph visualizations with it. Not sure about nested clusters though, never tried that out.
I've never done any UI programming in python before. What is the best (read most intuitive, easy to use, functional) UI package for python for doing simulations?
I'll be doing a simulation of TSP right now. So I'll have a graph (nodes and edges) where the edges are rapidly changing, along with some selection boxes to choose different styles of the algorithm, choose the number of nodes, etc..
I've already written this code with a command line interface and I'm hoping for something pretty seamless to port in a gui :)
I am not sure what you mean by "simulations" since the type of UI you want to do depends on what you simulate. But if you want to visualize graphs, networkx is pretty cool.
Such a simulation could be easily coded using:
networkx - for the graph data structures and algorithms
matplotlib - which is used by networkx to visualize graphs
Some GUI framework - PyQt, for instance, for the display and interaction with the user
What's cool is that these can be learned and tried separately. networkx is very powerful and can provide anything you need graph-vise. It works well with matplotlib, and you can show the steps of TSP by different colorings of edges/nodes. matplotlib can also be easily integrated with PyQt to put it all into a single interactive program.
Colleagues of mine are working on a similar-sounding setup to you - they use http://matplotlib.sourceforge.net/ and PyQt - PyQt can add a matplotlib object easily as a widget so the two integrate very well. A tutorial for PyQt is available here: http://www.zetcode.com/tutorials/pyqt4/
If you have graphs, you should definitely check out PyGraphviz (the interface is pretty similar to the aforementioned networkx)