PyNarrative: A Python Library for Data Storytelling
angelicaloduca
353 views
21 slides
Mar 25, 2025
Slide 1 of 21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
About This Presentation
PyNarrative is a Python library for data storytelling.
More details here:
https://github.com/pynarrative/pynarrative
Install PyNarrative as follows:
pip install pynarrative
Size: 557.9 KB
Language: en
Added: Mar 25, 2025
Slides: 21 pages
Slide Content
PyNarrative: A Python Library
for Data Storytelling
Angelica Lo Duca, Roberto Olinto Barsotti
Introduction
PyNarrative is a Python library we created and developed to facilitate data
narration.
The central theme of the work is the integration of technology and
communication through data storytelling.
There is a big gap between developers
and the communication of data, as
they often lack the necessary skills to
convey them clearly and effectively
The current survey of data visualisation libraries
includes:
State of the Art
for Python:
•Matplotlib: specializing in static and interactive graphs
•Seaborn: focused on statistical graphs
•Plotly: oriented towards web views
•Altair: characterised by a declarative approach
For other languages:
State of the Art
•D3.js for JavaScript
•ggplot2 for R
•JFreeChart for Java
However, these libraries focus mainly on
visualisation, neglecting the narrative aspect.
Data scientists face different challenges:
The Problem
•Existing tools, although powerful, are complex
to use
•Dozens of lines of code are needed to
implement narrative elements
•Different applications are necessary
•Communication with a non-technical audience
is difficult
To create a simple story using Altair requires
more than 100 lines of code , resulting in a
time-consuming technical set-up rather than
storytelling.
WHAT IS PYNARRATIVE?
PyNarrative is a library designed to integrate narrative
elements seamlessly into data visualization.
Instead of writing too many lines of code to add explanations,
annotations, and context, PyNarrative simplifies this process
with structured storytelling components.
PyNarrative was created with the aim of bridging the gap
between visualisation and data narration. Key features include:
Introduction to PyNarrative
•Integration with Altair as a technology base
•A structured narrative approach
•Significant reduction in code complexity
KEY INNOVATIONS:
●First library to natively implement full narrative structure
●Smooth and natural integration of all narrative elements
●Support for different cultures and reading styles
Story composition in 3 acts
The three fundamental parts of every story (Aristotle, 335 BC):
●MIDDLE: The core of the narrative
○The main visual representation with integrated annotations
○Supported by functions like add_annotation() and
add_source()
●END: Conclusions and future actions
○Guides the audience towards insights and next steps
○Implemented using add_next_steps(), offering various
interaction modes
●BEGINNING: Context and background
○Helps set the stage by providing relevant background
information
○Implemented using the add_context() function
Context
Context
Next Steps
Next Steps
Annotation
Credits
Credits
Credits
Credits
The empirical comparison between PyNarrative
and the traditional approach shows:
Results and Benefits
PyNarrative Traditional approach
Development time 10-15 minutes 70-100+ minutes
Code lines less than 20 beyond 100
Impact and Future
Future prospects may include:
Future Developments
Integration with AI:
•Automated context generation
•Image creation
•Annotation tips
•Layout optimization
Expansion of
functionalities:
•New display types
•Advanced narrative templates
•Support for complex datasets
The project achieved important goals:
Conclusions
•Significant reduction in complexity
•Improved data communication
•Effective narrative support
Repository Links:
https://github.com/pynarrativ
e/pynarrative?tab=readme-o
v-file
https://pynarrative.github.io/doc/p
ynarrative.html
Api documentation: