📜  图散景 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:53.837000             🧑  作者: Mango

代码示例1
from bokeh.models import HoverTool
from bokeh.palettes import Category20_20
from bokeh.io import show, output_notebook
from bokeh.plotting import figure
import networkx as nx
from bokeh.models import Range1d, Plot
from bokeh.plotting import from_networkx

G = nx.desargues_graph()

# We could use figure here but don't want all the axes and titles
plot = Plot(x_range=Range1d(-2, 2), y_range=Range1d(-2, 2))

# Create a Bokeh graph from the NetworkX input using nx.spring_layout
graph = from_networkx(G, nx.spring_layout, scale=1.8, center=(0,0))
plot.renderers.append(graph)

# Set some of the default node glyph (Circle) properties
graph.node_renderer.glyph.update(size=20, fill_color="orange")

# Set some edge properties too
graph.edge_renderer.glyph.line_dash = [2,2]

show(plot)
#https://hub.gke2.mybinder.org/user/bokeh-bokeh-notebooks-ckm45w5f/notebooks/tutorial/08%20-%20Graph%20and%20Network%20Plots.ipynb