SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Brian Coffey
Data Scientist, Stitch Fix
PyData NYC 2015
D3 in Jupyter
https://github.com/stitchfix/d3-jupyter-tutorial
Overview
1. Why you may occasionally wish to do this (but likely not all the time)
2. Hello DOM!
3. Meet bl.ocks.org, I think you’ll be great friends
4. A simple D3 scatterplot in Jupyter
5. A bar chart with interactivity (hello again DOM!)
6. Networks, maps and more
7. D3_lib.py (if you want to)
8. Discussion: From sketch to notebook frame
Why not all the time?
matplotlib, mpld3, bokeh, seaborn, toyplot, vispy, vincent, …
1. Why you may occasionally wish to do this (but likely not all the time)
Why not all the time?
matplotlib, mpld3, bokeh, seaborn, toyplot, vispy, vincent, …
Okay. Then why bother at all?
1. Maybe you just want the ultimate freedom in your data visualization, and
you happen to have some extra time on your hands, and/or you happen
to be a D3 wiz.
2. Maybe the perfect visualization for your analytical needs is not readily
available with other graphing tools, but there is a D3 example out there
that would be perfect with just some minor tweaks.
3. Maybe you are collaborating with a front-end person on a custom viz
1. Why you may occasionally wish to do this (but likely not all the time)
Just a heads up before we dig in.
If you are not already familiar with html, css and javascript, your eyes may
glaze over a bit during the first part of this tutorial.
But get what you can out of it, as understanding how it works will help you
to make the most of D3 in your Jupyter notebooks. I will try to be very clear
on the essential pieces of information you need to function, and on the
major gotchas for troubleshooting.
And if you get too lost, fear not. At the other end, there is a small helper
library and a collection of examples that you can use straight out of the box.
https://github.com/stitchfix/d3-jupyter-tutorial
2. Hello DOM!
“Oh, you can just call me Document Object Model for short”
Check me out in your browser’s development tools. Highlight a particular
element using the magnifying glass.
notebook: hello_dom.ipynb
from IPython.core.display import HTML
HTML( ‘<h1>Hello DOM!</h1>’ )
in general … HTML( [insert a html string here and I will put it in the DOM] )
(I will put it in the div assigned to the output_result of the code block that I am in.)
2. Hello DOM! hello_dom.ipynb
Let’s add some style…
HTML(‘
<style> … </style>
<h1 class=“steely”>Hello DOM!</h1>’)
2. Hello DOM! hello_dom.ipynb
And some javascript to modify the newly-added DOM element
HTML( ‘…
<h1 class=“steely” id=“steely-DOM”>Hello DOM!</h1>
<script>$(‘steely-DOM’).text(“Hello JavaScript!!!”)</script>’)
2. Hello DOM! hello_dom.ipynb
Great. But how does D3 fit into this?
D3 is a JavaScript library. The Ds are for Data Driven Documents.
Think ‘Data Driven DOM’.
A core aspect of using the D3 library is the following pattern:
1. Select some array of DOM elements
Note that this may be an empty array
2. ‘Attach’ an array of data to that array of DOM elements
The array lengths need not match. Extra data may ‘enter’, or DOM elements may ‘exit’. D3
coordinates all of this with elegance.
3. Perform some actions for each element in the data array
This will generally involve modifying the selected DOM elements, or removing or appending
new DOM elements, based on the values of the data array.
2. Hello DOM! hello_dom.ipynb
Appending elements to the DOM with D3
2. Hello DOM! hello_dom.ipynb
Just one last step – writing data from Python into the JavaScript for use by
D3
2. Hello DOM! hello_dom.ipynb
A Brief Review of Key Points:
IPython.core.display.HTML allows you to directly write new DOM elements
With that HTML function, we can add css (<style>) and javascript (<script>)
elements, as well as <div> elements (or <h1> elements, etc) for them to act
on
D3 is a clever javascript library for DOM modification based on arrays of
data
We can write python data directly into <script> element text so that it can be
acted upon by D3.
2. Hello DOM! hello_dom.ipynb
for any late-joiners:
https://github.com/stitchfix/d3-jupyter-tutorial
A Brief Review of Key Points:
IPython.core.display.HTML allows you to directly write new DOM elements
With that HTML function, we can add css (<style>) and javascript (<script>)
elements, as well as <div> elements (or <h1> elements, etc) for them to act
on
D3 is a clever javascript library for DOM modification based on arrays of
data
We can write python data directly into <script> element text so that it can be
acted upon by D3.
2. Hello DOM! hello_dom.ipynb
https://github.com/stitchfix/d3-jupyter-tutorial
Sure. Great. But I haven’t seen any data visualizations yet…
3. Meet bl.ocks.org, I think you’ll be great friends
http://bl.ocks.org/mbostock/4063269http://bl.ocks.org/mbostock/1353700http://bl.ocks.org/mbostock/4060954
d3js.org , bl.ocks.org/mbostock
(And welcome to data visualization heaven)
http://bl.ocks.org/mbostock/4060954
Anatomy of a bl.ock
Pretty graphic, often interactive
Short description
html, css and javascript that
produces the graphic
data that gets read by script,
usually in csv or tsv form
3. Meet bl.ocks.org, I think you’ll be great friends
Using this bl.ocks example: http://bl.ocks.org/mbostock/3887118
We will produce this in Jupyter:
4. A simple D3 scatterplot in Jupyter iris_scatterplot.ipynb
5. A bar chart with interactivity bar_chart_with_update.ipynb
(hello again DOM!)
watch out for the twist…
6. Networks, maps and more
sigma_js_graph.ipynb
temperature_histories.ipynb
polyFill_d3.ipynb
3d_meshing.ipynb
7. D3_lib.py (if you want to) multiple_simple_examples.ipynb
We have encapsulated a lot of the boilerplate for this method into an
external python file, which in turn calls external files containing your css
and js templates.
This just helps to keep things visually clean.
Feel free to use it as is and/or modify it to suit your needs.
8. Discussion: From sketch to notebook frame randomized_sketch.ipynb
Data Science @ Stitch
Fixbcoffey@stitchfix.com multithreaded.stitchfix.com
Thank you!

Weitere ähnliche Inhalte

Was ist angesagt?

The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
 
TensorFlow.Data 및 TensorFlow Hub
TensorFlow.Data 및 TensorFlow HubTensorFlow.Data 및 TensorFlow Hub
TensorFlow.Data 및 TensorFlow HubJeongkyu Shin
 
An Introduction to TensorFlow architecture
An Introduction to TensorFlow architectureAn Introduction to TensorFlow architecture
An Introduction to TensorFlow architectureMani Goswami
 
Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2Jay Coskey
 
Pitfalls of object_oriented_programming_gcap_09
Pitfalls of object_oriented_programming_gcap_09Pitfalls of object_oriented_programming_gcap_09
Pitfalls of object_oriented_programming_gcap_09Royce Lu
 
the productive programer: mechanics
the productive programer: mechanicsthe productive programer: mechanics
the productive programer: mechanicselliando dias
 
Python Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | EdurekaPython Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | EdurekaEdureka!
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++Mike Acton
 
refORM: Death to ORMs in .NET
refORM: Death to ORMs in .NETrefORM: Death to ORMs in .NET
refORM: Death to ORMs in .NETJames Hughes
 
FireWorks workflow software
FireWorks workflow softwareFireWorks workflow software
FireWorks workflow softwareAnubhav Jain
 
Textual Modeling Framework Xtext
Textual Modeling Framework XtextTextual Modeling Framework Xtext
Textual Modeling Framework XtextSebastian Zarnekow
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Hermann Hueck
 
Tensorflow internal
Tensorflow internalTensorflow internal
Tensorflow internalHyunghun Cho
 

Was ist angesagt? (20)

Pythonpresent
PythonpresentPythonpresent
Pythonpresent
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
TensorFlow.Data 및 TensorFlow Hub
TensorFlow.Data 및 TensorFlow HubTensorFlow.Data 및 TensorFlow Hub
TensorFlow.Data 및 TensorFlow Hub
 
An Introduction to TensorFlow architecture
An Introduction to TensorFlow architectureAn Introduction to TensorFlow architecture
An Introduction to TensorFlow architecture
 
Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2
 
Pitfalls of object_oriented_programming_gcap_09
Pitfalls of object_oriented_programming_gcap_09Pitfalls of object_oriented_programming_gcap_09
Pitfalls of object_oriented_programming_gcap_09
 
NANO266 - Lecture 9 - Tools of the Modeling Trade
NANO266 - Lecture 9 - Tools of the Modeling TradeNANO266 - Lecture 9 - Tools of the Modeling Trade
NANO266 - Lecture 9 - Tools of the Modeling Trade
 
MAVRL Workshop 2014 - pymatgen-db & custodian
MAVRL Workshop 2014 - pymatgen-db & custodianMAVRL Workshop 2014 - pymatgen-db & custodian
MAVRL Workshop 2014 - pymatgen-db & custodian
 
the productive programer: mechanics
the productive programer: mechanicsthe productive programer: mechanics
the productive programer: mechanics
 
Python Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | EdurekaPython Interview Questions And Answers 2019 | Edureka
Python Interview Questions And Answers 2019 | Edureka
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++
 
refORM: Death to ORMs in .NET
refORM: Death to ORMs in .NETrefORM: Death to ORMs in .NET
refORM: Death to ORMs in .NET
 
FireWorks workflow software
FireWorks workflow softwareFireWorks workflow software
FireWorks workflow software
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Task and Data Parallelism
Task and Data ParallelismTask and Data Parallelism
Task and Data Parallelism
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Textual Modeling Framework Xtext
Textual Modeling Framework XtextTextual Modeling Framework Xtext
Textual Modeling Framework Xtext
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8
 
Tensorflow internal
Tensorflow internalTensorflow internal
Tensorflow internal
 
Perl-C/C++ Integration with Swig
Perl-C/C++ Integration with SwigPerl-C/C++ Integration with Swig
Perl-C/C++ Integration with Swig
 

Andere mochten auch

Unsupervised Computer Vision: The Current State of the Art
Unsupervised Computer Vision: The Current State of the ArtUnsupervised Computer Vision: The Current State of the Art
Unsupervised Computer Vision: The Current State of the ArtTJ Torres
 
Jupyter Kernel: How to Speak in Another Language
Jupyter Kernel: How to Speak in Another LanguageJupyter Kernel: How to Speak in Another Language
Jupyter Kernel: How to Speak in Another LanguageWey-Han Liaw
 
Interactive Data Visualization (with D3.js)
Interactive Data Visualization (with D3.js)Interactive Data Visualization (with D3.js)
Interactive Data Visualization (with D3.js)Lynn Cherny
 
Jupyter, A Platform for Data Science at Scale
Jupyter, A Platform for Data Science at ScaleJupyter, A Platform for Data Science at Scale
Jupyter, A Platform for Data Science at ScaleMatthias Bussonnier
 
Introduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven DocumentsIntroduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven DocumentsMichał Oniszczuk
 
Big Data visualization with Apache Spark and Zeppelin
Big Data visualization with Apache Spark and ZeppelinBig Data visualization with Apache Spark and Zeppelin
Big Data visualization with Apache Spark and Zeppelinprajods
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with DataSeth Familian
 
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...John Fonner
 
Data to Go: Mobile API Design
Data to Go: Mobile API DesignData to Go: Mobile API Design
Data to Go: Mobile API DesignChuck Greb
 
Building Mobile Dashboards With D3 and Google Charts
Building Mobile Dashboards With D3 and Google ChartsBuilding Mobile Dashboards With D3 and Google Charts
Building Mobile Dashboards With D3 and Google ChartsSalesforce Developers
 
The Compatibility Challenge:Examining R and Developing TERR
The Compatibility Challenge:Examining R and Developing TERRThe Compatibility Challenge:Examining R and Developing TERR
The Compatibility Challenge:Examining R and Developing TERRLou Bajuk
 
Veracity Embracing Uncertainty
Veracity Embracing UncertaintyVeracity Embracing Uncertainty
Veracity Embracing UncertaintyGalen Murdock
 
OSINT using Twitter & Python
OSINT using Twitter & PythonOSINT using Twitter & Python
OSINT using Twitter & Python37point2
 
Introduction to data visualisation with D3
Introduction to data visualisation with D3Introduction to data visualisation with D3
Introduction to data visualisation with D3Aleksander Fabijan
 
Hear no evil, see no evil, patch no evil: Or, how to monkey-patch safely.
Hear no evil, see no evil, patch no evil: Or, how to monkey-patch safely.Hear no evil, see no evil, patch no evil: Or, how to monkey-patch safely.
Hear no evil, see no evil, patch no evil: Or, how to monkey-patch safely.Graham Dumpleton
 
Jupyterの機能を拡張してみた
Jupyterの機能を拡張してみたJupyterの機能を拡張してみた
Jupyterの機能を拡張してみたtaka400k
 
Examples of D3 Visualizations
Examples of D3 VisualizationsExamples of D3 Visualizations
Examples of D3 VisualizationsMD AMAN KHAN
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tipsLearningTech
 
Advanced D3 Charting
Advanced D3 ChartingAdvanced D3 Charting
Advanced D3 Chartingdcryan
 
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)Future Insights
 

Andere mochten auch (20)

Unsupervised Computer Vision: The Current State of the Art
Unsupervised Computer Vision: The Current State of the ArtUnsupervised Computer Vision: The Current State of the Art
Unsupervised Computer Vision: The Current State of the Art
 
Jupyter Kernel: How to Speak in Another Language
Jupyter Kernel: How to Speak in Another LanguageJupyter Kernel: How to Speak in Another Language
Jupyter Kernel: How to Speak in Another Language
 
Interactive Data Visualization (with D3.js)
Interactive Data Visualization (with D3.js)Interactive Data Visualization (with D3.js)
Interactive Data Visualization (with D3.js)
 
Jupyter, A Platform for Data Science at Scale
Jupyter, A Platform for Data Science at ScaleJupyter, A Platform for Data Science at Scale
Jupyter, A Platform for Data Science at Scale
 
Introduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven DocumentsIntroduction to data visualisations with d3.js — Data Driven Documents
Introduction to data visualisations with d3.js — Data Driven Documents
 
Big Data visualization with Apache Spark and Zeppelin
Big Data visualization with Apache Spark and ZeppelinBig Data visualization with Apache Spark and Zeppelin
Big Data visualization with Apache Spark and Zeppelin
 
Visual Design with Data
Visual Design with DataVisual Design with Data
Visual Design with Data
 
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...
Jupyter Ascending: a practical hand guide to galactic scale, reproducible dat...
 
Data to Go: Mobile API Design
Data to Go: Mobile API DesignData to Go: Mobile API Design
Data to Go: Mobile API Design
 
Building Mobile Dashboards With D3 and Google Charts
Building Mobile Dashboards With D3 and Google ChartsBuilding Mobile Dashboards With D3 and Google Charts
Building Mobile Dashboards With D3 and Google Charts
 
The Compatibility Challenge:Examining R and Developing TERR
The Compatibility Challenge:Examining R and Developing TERRThe Compatibility Challenge:Examining R and Developing TERR
The Compatibility Challenge:Examining R and Developing TERR
 
Veracity Embracing Uncertainty
Veracity Embracing UncertaintyVeracity Embracing Uncertainty
Veracity Embracing Uncertainty
 
OSINT using Twitter & Python
OSINT using Twitter & PythonOSINT using Twitter & Python
OSINT using Twitter & Python
 
Introduction to data visualisation with D3
Introduction to data visualisation with D3Introduction to data visualisation with D3
Introduction to data visualisation with D3
 
Hear no evil, see no evil, patch no evil: Or, how to monkey-patch safely.
Hear no evil, see no evil, patch no evil: Or, how to monkey-patch safely.Hear no evil, see no evil, patch no evil: Or, how to monkey-patch safely.
Hear no evil, see no evil, patch no evil: Or, how to monkey-patch safely.
 
Jupyterの機能を拡張してみた
Jupyterの機能を拡張してみたJupyterの機能を拡張してみた
Jupyterの機能を拡張してみた
 
Examples of D3 Visualizations
Examples of D3 VisualizationsExamples of D3 Visualizations
Examples of D3 Visualizations
 
D3js learning tips
D3js learning tipsD3js learning tips
D3js learning tips
 
Advanced D3 Charting
Advanced D3 ChartingAdvanced D3 Charting
Advanced D3 Charting
 
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
THE DATA DRIVEN WEB OF NOW: EXTENDING D3JS (Travis Smith)
 

Ähnlich wie D3 in Jupyter : PyData NYC 2015

Reactive datastore demo (2020 03-21)
Reactive datastore demo (2020 03-21)Reactive datastore demo (2020 03-21)
Reactive datastore demo (2020 03-21)YangJerng Hwa
 
Dojo: Getting Started Today
Dojo: Getting Started TodayDojo: Getting Started Today
Dojo: Getting Started TodayGabriel Hamilton
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1benDesigning
 
Advanced Module development
Advanced Module developmentAdvanced Module development
Advanced Module developmentdrupalindia
 
Breaking first-normal form with Hive
Breaking first-normal form with HiveBreaking first-normal form with Hive
Breaking first-normal form with HiveEdward Capriolo
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?Colin Riley
 
A Quick and Dirty D3.js Tutorial
A Quick and Dirty D3.js TutorialA Quick and Dirty D3.js Tutorial
A Quick and Dirty D3.js TutorialYoung-Ho Kim
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module DevelopmentSumeet Pareek
 
Theme customisation for beginners
Theme customisation for beginnersTheme customisation for beginners
Theme customisation for beginnersGareth J Barnard
 
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018Esteve Castells
 
DN18 | The Data Janitor Returns | Daniel Molnar | Oberlo/Shopify
DN18 | The Data Janitor Returns | Daniel Molnar | Oberlo/Shopify DN18 | The Data Janitor Returns | Daniel Molnar | Oberlo/Shopify
DN18 | The Data Janitor Returns | Daniel Molnar | Oberlo/Shopify Dataconomy Media
 
The Data Janitor Returns | Daniel Molnar | DN18
The Data Janitor Returns | Daniel Molnar | DN18The Data Janitor Returns | Daniel Molnar | DN18
The Data Janitor Returns | Daniel Molnar | DN18DataconomyGmbH
 
Open frameworks 101_fitc
Open frameworks 101_fitcOpen frameworks 101_fitc
Open frameworks 101_fitcbenDesigning
 
Infrastructure as code might be literally impossible part 2
Infrastructure as code might be literally impossible part 2Infrastructure as code might be literally impossible part 2
Infrastructure as code might be literally impossible part 2ice799
 

Ähnlich wie D3 in Jupyter : PyData NYC 2015 (20)

Reactive datastore demo (2020 03-21)
Reactive datastore demo (2020 03-21)Reactive datastore demo (2020 03-21)
Reactive datastore demo (2020 03-21)
 
Dojo: Getting Started Today
Dojo: Getting Started TodayDojo: Getting Started Today
Dojo: Getting Started Today
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1
 
Advanced Module development
Advanced Module developmentAdvanced Module development
Advanced Module development
 
Breaking first-normal form with Hive
Breaking first-normal form with HiveBreaking first-normal form with Hive
Breaking first-normal form with Hive
 
Test02
Test02Test02
Test02
 
HTML literals, the JSX of the platform
HTML literals, the JSX of the platformHTML literals, the JSX of the platform
HTML literals, the JSX of the platform
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?
 
A Quick and Dirty D3.js Tutorial
A Quick and Dirty D3.js TutorialA Quick and Dirty D3.js Tutorial
A Quick and Dirty D3.js Tutorial
 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module Development
 
Untangling7
Untangling7Untangling7
Untangling7
 
Theme customisation for beginners
Theme customisation for beginnersTheme customisation for beginners
Theme customisation for beginners
 
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
Advanced Web Scraping or How To Make Internet Your Database #seoplus2018
 
All of javascript
All of javascriptAll of javascript
All of javascript
 
Forensic Theming - DrupalCon London
Forensic Theming - DrupalCon LondonForensic Theming - DrupalCon London
Forensic Theming - DrupalCon London
 
DN18 | The Data Janitor Returns | Daniel Molnar | Oberlo/Shopify
DN18 | The Data Janitor Returns | Daniel Molnar | Oberlo/Shopify DN18 | The Data Janitor Returns | Daniel Molnar | Oberlo/Shopify
DN18 | The Data Janitor Returns | Daniel Molnar | Oberlo/Shopify
 
The Data Janitor Returns | Daniel Molnar | DN18
The Data Janitor Returns | Daniel Molnar | DN18The Data Janitor Returns | Daniel Molnar | DN18
The Data Janitor Returns | Daniel Molnar | DN18
 
Open frameworks 101_fitc
Open frameworks 101_fitcOpen frameworks 101_fitc
Open frameworks 101_fitc
 
Infrastructure as code might be literally impossible part 2
Infrastructure as code might be literally impossible part 2Infrastructure as code might be literally impossible part 2
Infrastructure as code might be literally impossible part 2
 
Shifting Gears
Shifting GearsShifting Gears
Shifting Gears
 

Kürzlich hochgeladen

Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...Suhani Kapoor
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改atducpo
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 

Kürzlich hochgeladen (20)

VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
VIP High Class Call Girls Jamshedpur Anushka 8250192130 Independent Escort Se...
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
代办国外大学文凭《原版美国UCLA文凭证书》加州大学洛杉矶分校毕业证制作成绩单修改
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 

D3 in Jupyter : PyData NYC 2015

  • 1. Brian Coffey Data Scientist, Stitch Fix PyData NYC 2015 D3 in Jupyter
  • 3. Overview 1. Why you may occasionally wish to do this (but likely not all the time) 2. Hello DOM! 3. Meet bl.ocks.org, I think you’ll be great friends 4. A simple D3 scatterplot in Jupyter 5. A bar chart with interactivity (hello again DOM!) 6. Networks, maps and more 7. D3_lib.py (if you want to) 8. Discussion: From sketch to notebook frame
  • 4. Why not all the time? matplotlib, mpld3, bokeh, seaborn, toyplot, vispy, vincent, … 1. Why you may occasionally wish to do this (but likely not all the time)
  • 5. Why not all the time? matplotlib, mpld3, bokeh, seaborn, toyplot, vispy, vincent, … Okay. Then why bother at all? 1. Maybe you just want the ultimate freedom in your data visualization, and you happen to have some extra time on your hands, and/or you happen to be a D3 wiz. 2. Maybe the perfect visualization for your analytical needs is not readily available with other graphing tools, but there is a D3 example out there that would be perfect with just some minor tweaks. 3. Maybe you are collaborating with a front-end person on a custom viz 1. Why you may occasionally wish to do this (but likely not all the time)
  • 6. Just a heads up before we dig in. If you are not already familiar with html, css and javascript, your eyes may glaze over a bit during the first part of this tutorial. But get what you can out of it, as understanding how it works will help you to make the most of D3 in your Jupyter notebooks. I will try to be very clear on the essential pieces of information you need to function, and on the major gotchas for troubleshooting. And if you get too lost, fear not. At the other end, there is a small helper library and a collection of examples that you can use straight out of the box. https://github.com/stitchfix/d3-jupyter-tutorial
  • 7. 2. Hello DOM! “Oh, you can just call me Document Object Model for short” Check me out in your browser’s development tools. Highlight a particular element using the magnifying glass. notebook: hello_dom.ipynb
  • 8. from IPython.core.display import HTML HTML( ‘<h1>Hello DOM!</h1>’ ) in general … HTML( [insert a html string here and I will put it in the DOM] ) (I will put it in the div assigned to the output_result of the code block that I am in.) 2. Hello DOM! hello_dom.ipynb
  • 9. Let’s add some style… HTML(‘ <style> … </style> <h1 class=“steely”>Hello DOM!</h1>’) 2. Hello DOM! hello_dom.ipynb
  • 10. And some javascript to modify the newly-added DOM element HTML( ‘… <h1 class=“steely” id=“steely-DOM”>Hello DOM!</h1> <script>$(‘steely-DOM’).text(“Hello JavaScript!!!”)</script>’) 2. Hello DOM! hello_dom.ipynb
  • 11. Great. But how does D3 fit into this? D3 is a JavaScript library. The Ds are for Data Driven Documents. Think ‘Data Driven DOM’. A core aspect of using the D3 library is the following pattern: 1. Select some array of DOM elements Note that this may be an empty array 2. ‘Attach’ an array of data to that array of DOM elements The array lengths need not match. Extra data may ‘enter’, or DOM elements may ‘exit’. D3 coordinates all of this with elegance. 3. Perform some actions for each element in the data array This will generally involve modifying the selected DOM elements, or removing or appending new DOM elements, based on the values of the data array. 2. Hello DOM! hello_dom.ipynb
  • 12. Appending elements to the DOM with D3 2. Hello DOM! hello_dom.ipynb
  • 13. Just one last step – writing data from Python into the JavaScript for use by D3 2. Hello DOM! hello_dom.ipynb
  • 14. A Brief Review of Key Points: IPython.core.display.HTML allows you to directly write new DOM elements With that HTML function, we can add css (<style>) and javascript (<script>) elements, as well as <div> elements (or <h1> elements, etc) for them to act on D3 is a clever javascript library for DOM modification based on arrays of data We can write python data directly into <script> element text so that it can be acted upon by D3. 2. Hello DOM! hello_dom.ipynb for any late-joiners: https://github.com/stitchfix/d3-jupyter-tutorial
  • 15. A Brief Review of Key Points: IPython.core.display.HTML allows you to directly write new DOM elements With that HTML function, we can add css (<style>) and javascript (<script>) elements, as well as <div> elements (or <h1> elements, etc) for them to act on D3 is a clever javascript library for DOM modification based on arrays of data We can write python data directly into <script> element text so that it can be acted upon by D3. 2. Hello DOM! hello_dom.ipynb https://github.com/stitchfix/d3-jupyter-tutorial Sure. Great. But I haven’t seen any data visualizations yet…
  • 16. 3. Meet bl.ocks.org, I think you’ll be great friends http://bl.ocks.org/mbostock/4063269http://bl.ocks.org/mbostock/1353700http://bl.ocks.org/mbostock/4060954 d3js.org , bl.ocks.org/mbostock (And welcome to data visualization heaven)
  • 17. http://bl.ocks.org/mbostock/4060954 Anatomy of a bl.ock Pretty graphic, often interactive Short description html, css and javascript that produces the graphic data that gets read by script, usually in csv or tsv form 3. Meet bl.ocks.org, I think you’ll be great friends
  • 18. Using this bl.ocks example: http://bl.ocks.org/mbostock/3887118 We will produce this in Jupyter: 4. A simple D3 scatterplot in Jupyter iris_scatterplot.ipynb
  • 19. 5. A bar chart with interactivity bar_chart_with_update.ipynb (hello again DOM!) watch out for the twist…
  • 20. 6. Networks, maps and more sigma_js_graph.ipynb temperature_histories.ipynb polyFill_d3.ipynb 3d_meshing.ipynb
  • 21. 7. D3_lib.py (if you want to) multiple_simple_examples.ipynb We have encapsulated a lot of the boilerplate for this method into an external python file, which in turn calls external files containing your css and js templates. This just helps to keep things visually clean. Feel free to use it as is and/or modify it to suit your needs.
  • 22. 8. Discussion: From sketch to notebook frame randomized_sketch.ipynb
  • 23. Data Science @ Stitch Fixbcoffey@stitchfix.com multithreaded.stitchfix.com Thank you!