pygraphistry-visualization

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PyGraphistry Visualization

PyGraphistry 可视化

Doc routing (local + canonical)

文档路由(本地 + 规范)

  • First route with
    ../pygraphistry/references/pygraphistry-readthedocs-toc.md
    .
  • Use
    ../pygraphistry/references/pygraphistry-readthedocs-top-level.tsv
    for section-level shortcuts.
  • Only scan
    ../pygraphistry/references/pygraphistry-readthedocs-sitemap.xml
    when a needed page is missing.
  • Use one batched discovery read before deep-page reads; avoid
    cat *
    and serial micro-reads.
  • Use local icon lookup notes from
    references/fa-icons.md
    .
  • In user-facing answers, prefer canonical
    https://pygraphistry.readthedocs.io/en/latest/...
    links.
  • 优先使用
    ../pygraphistry/references/pygraphistry-readthedocs-toc.md
    进行路由。
  • 使用
    ../pygraphistry/references/pygraphistry-readthedocs-top-level.tsv
    作为章节级快捷方式。
  • 仅在所需页面缺失时扫描
    ../pygraphistry/references/pygraphistry-readthedocs-sitemap.xml
  • 在深度页面读取前执行一次批量发现读取;避免使用
    cat *
    和串行微读取。
  • 使用
    references/fa-icons.md
    中的本地图标查找说明。
  • 在面向用户的回复中,优先使用规范链接
    https://pygraphistry.readthedocs.io/en/latest/...

Core pattern

核心模式

python
g2 = (
    # Keep a plain 'type' column on both nodes and edges for legend-friendly defaults
    g.bind(point_label='label', point_color='type', edge_color='type')
     .encode_point_color('type', categorical_mapping={'agent': '#3b82f6'}, default_mapping='#94a3b8')
     # Optional: default node sizing is often degree for exploratory passes
     .encode_point_size('degree')
     .settings(url_params={'play': 3000, 'info': True})
)
g2.plot()
python
g2 = (
    # 在节点和边中保留一个普通的'type'列,以获得便于图例展示的默认设置
    g.bind(point_label='label', point_color='type', edge_color='type')
     .encode_point_color('type', categorical_mapping={'agent': '#3b82f6'}, default_mapping='#94a3b8')
     # 可选:默认节点大小通常设置为度数,用于探索性分析
     .encode_point_size('degree')
     .settings(url_params={'play': 3000, 'info': True})
)
g2.plot()

External layout pattern

外部布局模式

python
undefined
python
undefined

nodes_df contains x/y layout columns

nodes_df 包含 x/y 布局列

g2 = graphistry.edges(edges_df, 'src', 'dst').nodes(nodes_df, 'id').bind(point_x='x', point_y='y').settings(url_params={'play': 0}) g2.plot()
undefined
g2 = graphistry.edges(edges_df, 'src', 'dst').nodes(nodes_df, 'id').bind(point_x='x', point_y='y').settings(url_params={'play': 0}) g2.plot()
undefined

URL parameters reference

URL 参数参考

Use
settings(url_params={...})
to control visualization behavior. Full reference: https://hub.graphistry.com/docs/api/1/rest/url/#urloptions
使用
settings(url_params={...})
控制可视化行为。完整参考:https://hub.graphistry.com/docs/api/1/rest/url/#urloptions

Layout

布局

ParamTypeDefaultRangeDescription
play
int50000-10000 (0, 1000, 2000, 5000)Layout duration ms. 0=fixed
lockedX
boolfalseLock X axis (with
bind(point_x=...)
)
lockedY
boolfalseLock Y axis (with
bind(point_y=...)
)
lockedR
boolfalseLock radial position
linLog
boolfalseStrong separation; good for <1000 nodes
scalingRatio
float1.00.1-10 (0.5, 1, 2, 5)Expansion ratio. Combine with
linLog
strongGravity
boolfalseCompact layout with pull to center
dissuadeHubs
boolfalseReduce hub dominance in layout
gravity
float1.00.1-10 (0.1, 1, 2, 10)Pull strength toward center
edgeInfluence
float1.00-10 (0, 0.7, 1, 2, 5, 7)Edge weight impact on layout
precisionVsSpeed
float1.00.1-10 (0.1, 1, 10)Higher=precise but slower
left/right/top/bottom
intautoManual camera bounds on load
参数类型默认值范围描述
play
int50000-10000(可选值:0, 1000, 2000, 5000)布局持续时间(毫秒)。0=固定布局
lockedX
boolfalse锁定X轴(需配合
bind(point_x=...)
使用)
lockedY
boolfalse锁定Y轴(需配合
bind(point_y=...)
使用)
lockedR
boolfalse锁定径向位置
linLog
boolfalse强分离模式;适用于节点数<1000的场景
scalingRatio
float1.00.1-10(可选值:0.5, 1, 2, 5)扩展比例。需与
linLog
配合使用
strongGravity
boolfalse紧凑布局,节点向中心聚拢
dissuadeHubs
boolfalse降低中心节点在布局中的主导性
gravity
float1.00.1-10(可选值:0.1, 1, 2, 10)节点向中心的拉力强度
edgeInfluence
float1.00-10(可选值:0, 0.7, 1, 2, 5, 7)边权重对布局的影响程度
precisionVsSpeed
float1.00.1-10(可选值:0.1, 1, 10)值越高精度越高,但速度越慢
left/right/top/bottom
intauto加载时手动设置相机边界

Scene / Rendering

场景/渲染

ParamTypeDefaultRangeDescription
pointSize
float1.00.1-10 (0.3, 0.5, 1, 2, 3)Point size multiplier (not encoding)
pointOpacity
float1.00-1 (0.3, 0.5, 0.8, 1)Node transparency
pointStrokeWidth
float00-5 (0, 1, 2)Node border width
edgeCurvature
float00-1 (0, 0.5, 1)Edge bending amount
edgeOpacity
float1.00-1 (0.3, 0.5, 0.8, 1)Edge transparency
showArrows
booltrueShow edge direction arrows
neighborhoodHighlight
strbothincoming/outgoing/both/nodeHover highlight mode
neighborhoodHighlightHops
int11-5 (1, 2, 3)Hops in hover highlight
参数类型默认值范围描述
pointSize
float1.00.1-10(可选值:0.3, 0.5, 1, 2, 3)节点大小乘数(非编码设置)
pointOpacity
float1.00-1(可选值:0.3, 0.5, 0.8, 1)节点透明度
pointStrokeWidth
float00-5(可选值:0, 1, 2)节点边框宽度
edgeCurvature
float00-1(可选值:0, 0.5, 1)边弯曲程度
edgeOpacity
float1.00-1(可选值:0.3, 0.5, 0.8, 1)边透明度
showArrows
booltrue显示边方向箭头
neighborhoodHighlight
strbothincoming/outgoing/both/node悬停高亮模式
neighborhoodHighlightHops
int11-5(可选值:1, 2, 3)悬停高亮的跳数

Labels / Points of Interest

标签/兴趣点

ParamTypeDefaultRangeDescription
showLabels
booltrueToggle all label visibility
showLabelOnHover
booltrueShow labels only on hover
showPointsOfInterest
booltrueHighlight key nodes as POI
showPointsOfInterestLabel
booltrueShow labels on POI nodes
pointsOfInterestMax
int50-100 (0, 5, 10, 20)Max POIs. 0=disable
shortenLabels
booltrueTruncate long labels
showLabelPropertiesOnHover
boolfalseShow extra properties on hover
labelOpacity
float1.00-1 (0.5, 0.8, 1)Label transparency
labelColor
strhex no # (000000, FFFFFF)Label text color
labelBackground
strhex no # (000000, FFFFFF)Label bg color
Note: URL params use hex without
#
. Python API (
encode_*
,
palette
) uses
#
prefix.
参数类型默认值范围描述
showLabels
booltrue切换所有标签的可见性
showLabelOnHover
booltrue仅在悬停时显示标签
showPointsOfInterest
booltrue将关键节点高亮为兴趣点(POI)
showPointsOfInterestLabel
booltrue显示兴趣点节点的标签
pointsOfInterestMax
int50-100(可选值:0, 5, 10, 20)最大兴趣点数量。0=禁用
shortenLabels
booltrue截断长标签
showLabelPropertiesOnHover
boolfalse悬停时显示额外属性
labelOpacity
float1.00-1(可选值:0.5, 0.8, 1)标签透明度
labelColor
str不带#的十六进制值(如000000, FFFFFF)标签文本颜色
labelBackground
str不带#的十六进制值(如000000, FFFFFF)标签背景颜色
注意:URL参数使用不带
#
的十六进制值。Python API(
encode_*
palette
)使用带
#
前缀的格式。

UI Controls

UI 控件

ParamTypeDefaultDescription
menu
booltrueShow all menus
info
booltrueShow graph size stats
showHistograms
booltrueShow histogram panel
showInspector
booltrueShow entity inspector
showCollections
boolfalseShow collections panel
参数类型默认值描述
menu
booltrue显示所有菜单
info
booltrue显示图表大小统计信息
showHistograms
booltrue显示直方图面板
showInspector
booltrue显示实体检查器
showCollections
boolfalse显示集合面板

Examples

示例

python
undefined
python
undefined

Ring layout with strong separation for small graphs (<1000 nodes)

环形布局,强分离模式适用于小型图表(<1000节点)

g2 = g.settings(url_params={'play': 3000, 'linLog': True, 'scalingRatio': 2.0})
g2 = g.settings(url_params={'play': 3000, 'linLog': True, 'scalingRatio': 2.0})

Fixed position layout (external coordinates)

固定位置布局(外部坐标)

g2 = g.bind(point_x='x', point_y='y').settings(url_params={'play': 0, 'lockedX': True, 'lockedY': True})
g2 = g.bind(point_x='x', point_y='y').settings(url_params={'play': 0, 'lockedX': True, 'lockedY': True})

Disable POI labels entirely

完全禁用兴趣点标签

g2 = g.settings(url_params={'showLabels': False, 'pointsOfInterestMax': 0})
g2 = g.settings(url_params={'showLabels': False, 'pointsOfInterestMax': 0})

Larger points, more transparent edges

更大的节点,更透明的边

g2 = g.settings(url_params={'pointSize': 3.0, 'edgeOpacity': 0.3})
g2 = g.settings(url_params={'pointSize': 3.0, 'edgeOpacity': 0.3})

Minimal UI for embedding

用于嵌入的极简UI

g2 = g.settings(url_params={'menu': False, 'info': False, 'showHistograms': False, 'showInspector': False})
undefined
g2 = g.settings(url_params={'menu': False, 'info': False, 'showHistograms': False, 'showInspector': False})
undefined

Icon/badge pattern

图标/徽章模式

python
g2 = (
    g.encode_point_icon('type', categorical_mapping={'person': 'user', 'org': 'building'})
     .encode_point_badge('risk', categorical_mapping={'high': 'exclamation-triangle'})
)
g2.plot()
Use valid Font Awesome names and keep icon mappings category-driven by
type
. See
references/fa-icons.md
for lookup links and examples.
python
g2 = (
    g.encode_point_icon('type', categorical_mapping={'person': 'user', 'org': 'building'})
     .encode_point_badge('risk', categorical_mapping={'high': 'exclamation-triangle'})
)
g2.plot()
使用有效的Font Awesome名称,并按
type
分类设置图标映射。 有关查找链接和示例,请查看
references/fa-icons.md

Continuous-color pattern (beyond categorical maps)

连续颜色模式(超越分类映射)

python
g2 = g.encode_edge_color('amount', palette=['#46327e', '#1fa187', '#fde724'], as_continuous=True)
g2.plot()
python
g2 = g.encode_edge_color('amount', palette=['#46327e', '#1fa187', '#fde724'], as_continuous=True)
g2.plot()

Focused subgraph views (collection-like workflow)

聚焦子图视图(类集合工作流)

python
undefined
python
undefined

Use GFQL slices to publish multiple focused views from one base graph (use .gfql(), not deprecated .chain())

使用GFQL切片从一个基础图表发布多个聚焦视图(使用.gfql(),而非已弃用的.chain())

high_risk = g.gfql([...]).name('high-risk-slice') partner_flow = g.gfql([...]).name('partner-flow-slice') urls = [high_risk.plot(render=False), partner_flow.plot(render=False)]
undefined
high_risk = g.gfql([...]).name('high-risk-slice') partner_flow = g.gfql([...]).name('partner-flow-slice') urls = [high_risk.plot(render=False), partner_flow.plot(render=False)]
undefined

Privacy-safe sharing pattern

隐私安全共享模式

python
graphistry.privacy(mode='private')
plot_url = g.plot(render=False)
  • Use explicit
    graphistry.privacy(mode='private'|'organization'|'public')
    before plotting share links.
  • Do not treat
    plot()
    kwargs like
    as_files
    or
    memoize
    as privacy controls.
python
graphistry.privacy(mode='private')
plot_url = g.plot(render=False)
  • 在生成共享链接前,显式使用
    graphistry.privacy(mode='private'|'organization'|'public')
    设置隐私模式。
  • 不要将
    plot()
    的参数(如
    as_files
    memoize
    )视为隐私控制手段。

Common tasks

常见任务

  • Encodings:
    encode_point_color
    ,
    encode_edge_color
    ,
    encode_point_size
    ,
    encode_point_icon
    ,
    encode_point_badge
    .
  • Layouts: runtime force layout settings, ring/GIB/modularity, graphviz/igraph/cugraph plugin layouts.
  • Static outputs:
    plot_static()
    for SVG/PNG and text engines like
    graphviz-dot
    /
    mermaid-code
    .
  • Sharing controls:
    graphistry.privacy(mode='private'|'organization'|'public')
    .
  • For advanced gradients, use
    palette=[...]
    with
    as_continuous=True
    on
    encode_point_color
    /
    encode_edge_color
    .
  • For large investigations, generate multiple focused GFQL slices instead of one overloaded plot.
  • 编码:
    encode_point_color
    encode_edge_color
    encode_point_size
    encode_point_icon
    encode_point_badge
  • 布局:运行时力导向布局设置、环形/GIB/模块化布局、graphviz/igraph/cugraph插件布局。
  • 静态输出:使用
    plot_static()
    生成SVG/PNG,以及
    graphviz-dot
    /
    mermaid-code
    等文本引擎输出。
  • 共享控制:
    graphistry.privacy(mode='private'|'organization'|'public')
  • 如需高级渐变效果,在
    encode_point_color
    /
    encode_edge_color
    中使用
    palette=[...]
    并设置
    as_continuous=True
  • 针对大型分析场景,生成多个聚焦GFQL切片,而非单个过载的图表。

Big-graph defaults

大图默认设置

  • Filter and aggregate before plotting.
  • Keep only essential columns (drop large text blobs unless needed).
  • Use focused subgraphs (time slice, one-hop neighborhood, top-k signals).
  • Prefer plain
    type
    columns on both nodes and edges so legends and default category encodings stay stable.
  • Avoid dotted column names like
    node.type
    /
    edge.type
    ; prefer plain names.
  • Use native datetime types for time encodings and time-sliced comparisons.
  • 绘图前先进行过滤和聚合。
  • 仅保留必要列(除非需要,否则删除大文本块)。
  • 使用聚焦子图(时间切片、单跳邻域、Top-K信号)。
  • 优先在节点和边中使用普通的
    type
    列,确保图例和默认分类编码保持稳定。
  • 避免使用
    node.type
    /
    edge.type
    这类带点的列名;优先使用普通名称。
  • 时间编码和时间切片对比使用原生日期时间类型。

Canonical docs

规范文档