简体   繁体   中英

How is it possible to draw unconnected nodes with networkx?

When using.networkx I only now that there are several possibilities of plotting graphs with edges and nodes.

Is it possible only to plot a lot of nodes, without connections between them? The points all have x- and y-coordinates. The points are saved in a pandas dataframe with only 3 columns: ID, X, Y

g = nx.from_pandas_dataframe(df1, source='x', target='y')

I tried something like this but I don´t want to have edges only points.

This is a part of the dataframe:

               id   x         y
0              550  1005.600  1539.400
1              551  1006.600  1549.400
2              705  1029.997  2140.001
3              706  1030.997  2141.001
4              478   180.000  1354.370
5              479   190.000  1354.370
..             ...       ...       ...
500            237  1135.000  2615.000
501            238  1145.000  2615.000

You can draw nodes and edges separately. Use the following to only draw the nodes:

nodes=nx.draw_networkx_nodes(G)

If you want to pass the specific position of the nodes you may want to create the pos out of the x and y values. (At that point I would rather not use.networkx...)

See the docs...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM