Layout: Draw vertex at the same position as the coordinates given by itself
Dear all,
I would like to generate a graph from a given dataset. The problem is, that I would like to have the vertex plotted at the same position in space as the initial data points represented by the vertex. However, this does not work so far with the default graph_draw() since it uses a standard layout. Do you have any ideas how to get there?
Here a sample code:
import gtk #need that-->otherwise I get weird gtk error
from graph_tool.all import *
import matplotlib.pyplot as plt
from sklearn import datasets
#generate dataset
np.random.seed(0)
n_samples = 30
[X,y] = datasets.make_moons(n_samples=n_samples, noise=.05)
#plot datasets
plt.scatter(X[:, 0], X[:, 1])
#generate graph from generated dataset
g = Graph(directed=False)
g.add_vertex(size(X,0))
v_features=g.new_vertex_property("vector<int>")
e_distance=g.new_edge_property("double")
for i in range(1,size(X,0)):
v_features[g.vertex(i)] = [X[i,0],X[i,1]]
This only plots the vertex with a specific layout, however I would like them to be in the same position in space as my data points illustrated by the vertex.
graph_draw(g, vertex_text=g.vertex_index, vertex_font_size=10, output_size=(400, 400), output="generated_graph.png")
Does a specific layout exist to fix this problem?
Kind Regards.