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)
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
Before we begin, ensure that you've properly installed the
pygwalker library. If not, you can install it using
pip install pygwalker
Saving configurations in a local JSON file is the most recommended method due to its convenience and portability.
Initialize the Walker with a JSON Spec Begin by pointing
pygwalkerto a local JSON file to which it can save its configurations:
import pygwalker as pyg walker = pyg.walk(df=df, spec="./my_charts.json")
Save Your Charts Once you've finished exploring your data, you'll notice a "save" button within the
pygwalkerinterface. Click on it. This action will save the current state of your visualizations to the specified JSON file.
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.
If you're keen on avoiding additional files, this method lets you store the configuration directly within your code.
Export Configuration Code Once you've set up and finished your visualization, locate and click on the
export codebutton in the
pygwalkerinterface. This action will generate a code snippet representing your current visualization setup.
Store the Configuration in the Notebook Copy the generated code snippet and use it as the specification in the
import pygwalker as pyg walker = pyg.walk(df=df, spec="<graphic-walker spec>")
<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!