-
Notifications
You must be signed in to change notification settings - Fork 698
How to save charts in juypter cell and share it with others?
You can check a tutorial ipynb file here
Storing Visualizations with Pygwalker
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
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
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")
-
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. -
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 code
button in thepygwalker
interface. 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
spec
parameter:import pygwalker as pyg walker = pyg.walk(df=df, spec="<graphic-walker spec>")
Replace
<graphic-walker spec>
with the copied code.
Conclusion 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!