Skip to content
How to save charts in juypter cell and share it with others?

How to save charts in juypter cell and share it with others?

You can check a tutorial ipynb file here (opens in a new tab)

Using the pygwalker library for data exploration provides an interactive way to view and analyze data. However, storing these visualizations is essential for future references, presentations, or sharing with peers. Let's walk through two methods to save your pygwalker charts.


Before we begin, ensure that you've properly installed the pygwalker library. If not, you can install it using pip:

pip install pygwalker

Method 1: Save charts with a local JSON file (recommended)

Saving configurations in a local JSON file is the most recommended method due to its convenience and portability.

  1. Initialize the Walker with a JSON Spec Begin by pointing pygwalker to a local JSON file to which it can save its configurations:

    import pygwalker as pyg
    walker = pyg.walk(df=df, spec="./my_charts.json")
  2. Save Your Charts Once you've finished exploring your data, you'll notice a "save" button within the pygwalker interface. Click on it. This action will save the current state of your visualizations to the specified JSON file. image

  3. Re-using and Sharing To revisit your saved configurations, simply load the JSON file. Moreover, if you intend to share your notebook, don't forget to include the JSON file for a complete experience.

Method 2: Save charts with specification code

If you're keen on avoiding additional files, this method lets you store the configuration directly within your code.

  1. Export Configuration Code Once you've set up and finished your visualization, locate and click on the export code button in the pygwalker interface. This action will generate a code snippet representing your current visualization setup. image

  2. Store the Configuration in the Notebook Copy the generated code snippet and use it as the specification in the spec parameter: image

    import pygwalker as pyg
    walker = pyg.walk(df=df, spec="<graphic-walker spec>")

    Replace <graphic-walker spec> with the copied code.



Both methods have their advantages. Using a local JSON file keeps your notebook clean and makes it easier to manage complex configurations. On the other hand, storing the specification directly in the notebook ensures everything is in one place. Choose the method that best suits your needs and happy data exploring!