Skip to content
PYGWALKER
API Reference
Specification (spec)

Specification spec

spec allows you to specify the data visualization directly. It can be used to display some pre-built visualizations. spec can be

  • JSON string of graphic-walker specification
  • Local JSON file path of graphic-walker specification
  • Remote spec of graphic-walker specification
import pygwalker as pyg
 
pyg.walk(df, spec='{ ...gw spec }')
pyg.walk(df, spec='path/to/spec.json')
pyg.walk(df, spec='k6s://example.com/path/to/spec.json')

How to get the specification of a visualization?

If you build a visualization in pygwalker UI, GWalkR UI, or any data exploration UI based on graphic-walker. You can get the specification of the chart by clicking the export code button in the toolbar of the UI.

JSON string as spec

import pygwalker as pyg
 
pyg.walk(df, spec='[{"config":{"defaultAggregated":true,"geoms":["auto"],"coordSystem":"generic","limit":-1},"encodings":{"dimensions":[{"fid":"gender","name":"gender","basename":"gender","semanticType":"nominal","analyticType":"dimension"},{"fid":"race/ethnicity","name":"race/ethnicity","basename":"race/ethnicity","semanticType":"nominal","analyticType":"dimension"},{"fid":"parental level of education","name":"parental level of education","basename":"parental level of education","semanticType":"nominal","analyticType":"dimension"},{"fid":"lunch","name":"lunch","basename":"lunch","semanticType":"nominal","analyticType":"dimension"},{"fid":"test preparation course","name":"test preparation course","basename":"test preparation course","semanticType":"nominal","analyticType":"dimension"},{"fid":"gw_mea_key_fid","name":"Measure names","analyticType":"dimension","semanticType":"nominal"}],"measures":[{"fid":"math score","name":"math score","basename":"math score","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"reading score","name":"reading score","basename":"reading score","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"writing score","name":"writing score","basename":"writing score","analyticType":"measure","semanticType":"quantitative","aggName":"sum"},{"fid":"gw_count_fid","name":"Row count","analyticType":"measure","semanticType":"quantitative","aggName":"sum","computed":true,"expression":{"op":"one","params":[],"as":"gw_count_fid"}},{"fid":"gw_mea_val_fid","name":"Measure values","analyticType":"measure","semanticType":"quantitative","aggName":"sum"}],"rows":[{"fid":"reading score","name":"reading score","basename":"reading score","analyticType":"measure","semanticType":"quantitative","aggName":"sum"}],"columns":[{"fid":"parental level of education","name":"parental level of education","basename":"parental level of education","semanticType":"nominal","analyticType":"dimension"}],"color":[],"opacity":[],"size":[],"shape":[],"radius":[],"theta":[],"longitude":[],"latitude":[],"geoId":[],"details":[],"filters":[],"text":[]},"layout":{"showActions":false,"showTableSummary":false,"stack":"stack","interactiveScale":false,"zeroScale":true,"size":{"mode":"auto","width":320,"height":200},"format":{},"geoKey":"name","resolve":{"x":false,"y":false,"color":false,"opacity":false,"shape":false,"size":false}},"visId":"gw_CUsw","name":"Chart 1"}])

Local JSON file path as spec

import pygwalker as pyg
 
pyg.walk(df, spec='path/to/spec.json')

Remote spec as spec

Remote spec is a cloud services provided by kanaries. You can use the k6s:// protocol to access the remote spec.

import pygwalker as pyg
 
pyg.walk(df, spec='k6s://example.com/path/to/spec.json')