Pivot point/anchor of node (Cytoscape.js) - cytoscape.js

I am loading a xlsx table with nodes.
The table has the x, y coordinates of the node, the names of the nodes, and something else.
I have a bunch of nodes with x coordinate = 0, but with different y coordinates.
When I load the nodes, because the pivot point of the nodes is in the center, I get this picture
I need a picture like this
I did not find any pivot point or anchor for the node in the documentation. If the x coordinate of the node would not work in the center, but along the right edge of the node, everything would be perfect

Ok, I think I solved the problem with this module https://github.com/iVis-at-Bilkent/cytoscape.js-grid-guide
I just find nodes with the same x coordinate and then call the align fn from module.
It looks something like this
nodesWithSameXCoord.align(null, "left", nodesWithSameXCoord[0])

Related

How to vertically align dagre parent nodes in cytoscape.js

I have a graph made in cytoscape.js, using the dagre extension, that looks like this:
Graph
How can I get the parent nodes to line up vertically? Since applying a separate layout to only parent nodes does not work (it applies to all nodes), I am stumped.
Unfortunately they are all poorly maintained visualization algorithms, so they don't have as many features.
I suggest you to open an issue in the algorithm repository where you explain how it can be improved.
In this case you would like to have a better aspect of the visualization.
https://github.com/cytoscape/cytoscape.js-dagre
You can also contribute to the dagre project adding this aesthetic criteria on to the graph.
At the end if you would like to have a better aspect you can apply a tweek to the graph after the layout execution.
So you can think to an algorithm for making parent nodes line up vertically and then apply in the code.
For example something you can do for having nodes nearest to their father and also a good aspect ratio you can sort nodes in the level n + 1 in the barycenter of their father in the lever n.
(let me know if I have made it clear)
I saw from the photo that you have groups, and the nodes within the group have different fathers, so if you put the nodes aligned with their fathers then you could have
Nodes that are overlapping
overlapping groups
groups with too large a width
(let me know if I have made the problem clear)
I remember you how to position nodes in cytoscape.js
cyGraph.startBatch(); // for bach the differences and apply only once at the end
// random layout. you have to use yours
cyGraph.nodes().positions(( node, i ) => {
return {
x: Math.random() * cyGraph.width(),
y: Math.random() * cyGraph.height(),
};
});
cyGraph.endBatch();

Why all vertices are removed after useing the option ' Remove unreferenced vertices

Im imported my pointcloud to Meshlab with normals and I would like to make a Screened Poisson Surface Reconstruction. When I try to do this I Have a communicat like ' Filters requires correct per vertes normals. E.g.it is necessary that your ALL input vertices have a proper, not-null normal. If you enconuter this error on a triangulated mesh try to use the Remove Unreferenced Vertices filters....'
When I tried use this options all my vertices disappeared. I also checked my normals and all have not-null value.
I don't understand where the problem is. Please help me.
Your input is not a triangulated mesh, so you should not call "Remove Unreferenced Vertices" filter. That filter will remove those vertex that are not in use by any triangle, which mean "every vertex" if you have no triangles.
Assuming your file is in .xyz format, you should have 6 numbers per vertex:
x coord, y coord, z coord, x normal, y normal, z normal
Most likely, your file only contains the coordinate data.
If you cannot add the normal information to the file, you can estimate it in Meshlab with:
Filters > Normals, Curvatures and Orientation > Compute normals for point sets

Drawing a data relationship diagram using networkx and matplotlib

I'm trying to draw a data relationship diagram. I've modeled my input data in triples (subject, predicate, object) e.g. (app, 'consumes', entity), (app, 'masters', entity), etc
Each triple is an edge and 2 nodes. I want to color different sets of nodes in different colors as well.
I'm struggling with setting the color attribute as well as saving the graph to a png file in a size that is readable
Here's the code :
G = nx.DiGraph ()
read input data from file and process is lists of nodes and edges
......
add nodes - set diff color for each set of nodes ??
G.add_nodes_from (list(entities), node_color='yellow')
G.add_nodes_from (list(sornodes))
G.add_nodes_from (list (consumernodes))
add edges - set diff color for each set of edges (how do I do this?)
G.add_edges_from (masters)
G.add_edges_from (consumers)
G.add_edges_from (ads)
pos = nx.spring_layout(G)
nx.draw_networkx_nodes(G, pos, node_size=1700)
nx.draw_networkx_edges (G, pos, arrow=True)
nx.draw_networkx_labels (G, pos)
nx.draw_spring (G)
plt.figure(figsize=(7.195, 3.841))
fig1 = plt.gcf()
fig1.savefig ('out.png', dpi=1000)
plt.show ()
There is no image in the file. plt.show pops up the graph in a new window and another empty window is opened as well. I'm running this from a bash shell. Closing both the image windows terminates the program.
I need to be able to show sets of nodes in different colors.
I need to be able to show sets of edges in different colors
I want to be able to size the graph to a large image - does not need to fit within a monitor size
Thoughts anyone ?
draw_networkx_nodes (...) does not seem like to multiple calls with different sets of nodes and different colors for each set. It uses the last color specified for all the nodes in the graph.
The solution is to call draw_networkx_nodes once and pass a list with colors for each node and list len same as number of nodes.
# s, c and a are 3 lists of nodes
for x in s:
nodes.append(x)
nodecolor.append('r')
for x in c:
nodes.append(x)
nodecolor.append('g')
for x in a:
nodes.append(x)
nodecolor.append('y')
G.add_nodes_from(nodes)
nx.draw_networkx_nodes(G, pos, node_color=nodecolor, node_size=1700)
I'm sure I could optimize the code for creating the lists.

Adding a second x axis to a TGraph in the CERN ROOT program

does anyone know the method or code to add a second x axis to a TGraph in CERN's ROOT program? Ive been searching the root website and its documentation almost always confuses me. What i need is just one plot of data, but a second X axis on top whose values are a function of the bottom x axis' values. Its basically so lazy people dont have to convert from the numbers of the bottom x axis to the top x axis.
For a simple example (if i wasnt clear)
Say you have a sine curve which is some function of theta. On the top x axis we could have degrees whereas on the bottom we could have radians with 360deg corresponding to 2pi rad...
Any help would be appreciated!
TGaxis is the class you are looking for to draw extra axes wherever you desire. Grabbing the world coordinate for your pad you can then superimpose like so. Replace low and high with the appropriate limits.
// your graph code here...
TGraph->Draw("AP");
TGaxis *axis = new TGaxis(gPad->GetUxmin(),gPad->GetUymax(),gPad->GetUxmax(),gPad->GetUymax(),low,high,510,"+L");
axis->Draw();
Check out TGaxis documentation for more examples.
(A previous answer I had was deleted as it was just a link to the site listed as a reference below. I hope this is more in line with the community guidelines.)
I think this might do what you want.
void axis2() {
TH1F *h = new TH1F("h","test",30,-3,3);
h->FillRandom("gaus",10000);
h->Draw();
TText t;
t.SetTextSize(0.02);
t.SetTextAlign(22);
Double_t yt = - h->GetMaximum()/15.;
for (Int_t i=1;i<=30;i++) t.DrawText(h->GetBinCenter(i),yt,Form("%d",i%10));
}
It doesn't create another taxis but shows you how to draw text at the same location of the axis. The answer comes from Rene Brun himself (one of the main authors of root) so I don't think you can have two x axes.
Source:
http://root.cern.ch/phpBB3/viewtopic.php?f=3&t=7110
Here is an example showing how to proceed.
https://root.cern/doc/master/twoscales_8C.html

How Do I Switch Y and Z Axises from Blender? (So Y is Up)

I've been having a bit of a problem with making the Y axis my up axis when exporting mesh and scenes from Blender. Both Blender and my export target use right handed transformation matrices. Z is the up axis in Blender while Y is the up axis in my target. The problem exists in 2 places though. The scene's transformations can't just be shifted on the X axis to fix this, because I also need to do the Y/Z switch for the vertices in the mesh (export as vertex.x, vertex.z, vertex.y). I need to have the actual Y and Z rotations switched, so that if the Y and Z rotations are the same, no change will occur (ie. identity). Thanks for your help in advance. Feel free to ask questions if I was not thorough enough.
Blender does two things different than the rest of the known world!
1. It uses Z axis for vertical (should be Y); Y axis for horizontal (should b X); and X axis for in and out (should b Z).
Very weird! Every high school graph since the beginning of time uses X for horizontal and Y for vertical.
It uses the right mouse button for selections.
U can change the selection btn in Preferences, but not the crazy axis arrangement!
no,
you do this
y=z
z=-y
no rotation of 90 degrees can make you go from left to right hand.
I ran into a similar issue when working with cinema4d and blender. In cinema4d Y is the up axis and rotations are heading,pitch and bank.
Blender's system looks like a right handed system, but rotated by 90 degrees on x axis.
I did the same thing for coordinates(exported as vertex.x,vertex.z,vertex.y). For rotations,
I think you should add 90 degrees(math.pi * 0.5) for rotations on X axis and the rest should be fine.
HTH
Have you tried just using Select All (the 'a' key) and then r x 90 to rotate everything 90 degrees around the X axis and the pivot point? (your pivot point is choosable in the menu bar of the 3D view if you need to control that).
You could do that, export, and then undo.
Just Download Wings3D. Export from Blender as .3ds and then Import this file in Wings3D.
Now you can just export it from Wings3D, again to .3ds. But instead of clicking directly on .3ds, click on the small icon in the right of the ".3ds" menu. now you can unchecked the Box Swap y und z axis and import the .3ds in another program.
There is no way that would be possible. Coordinate system was innately selected as hard coded from the blender source and there are no explicit option has been made in blender to switch it. It would also affected many of the hard coded functionality of any function blender was used or has been made by assume that coordinate
However, in theory, it would be possible to access blender source code and rebuild the blender to have it use another coordinate we would like. Albeit we need to carefully swap everything related to coordinate system
I too wish that left handed coordinate system (as of Unity3D) would be industrial standard and blender should at least have another version that work in left handed coordinate. People should just graduated from table coordinate to screen coordinate already
In blender, you could add empty plain axes, that will correct your orientation when exporting to unity, or try exporting as fbx file and change orientation in export options