Giter Club home page Giter Club logo

pythond3's Introduction

IPython & D3

(HUGE thanks to Monte Lunacek for teaching me his hack with the custom D3 module!)

Let's start with reviewing a few of the ideas for using JavaScript in IPython. We'll then work with some data in python and then build a few d3 visualizations. We'll conclude by crafting a custom module that can receive data and render the d3 viz!

JS with IPython?

The nice thing about ipython is that we can write in almost any lanaguage. For example, we can use javascript below and pull in the D3 library.

Python data | D3 Viz

A basic method is to serialze your results and then render html that pulls in the data. In this example, we save a json file and then load the html doc in an IFrame. We're now using D3 in ipython!

The example below is adapted from:

Passing data from IPython to JS

Let's create some random numbers and render them in js (see the stackoverflow explanation and discussion).

Passing data from JS to IPython

We can also interact with js to define python variables (see this example).

Custom D3 module.

Now we're having fun. The simplicity of this process wins. We can pass data to javascript via a module called visualize that contains an attribute plot_circle, which uses jinja to render our js template. The advantage of using jinja to read our html is apparent: we can pass variables directly from python!

Now we just need to learn how to write useful javacript! (Enter Jason)

pythond3's People

Contributors

blehman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.