C3.js and plotly.js for iPython/Jupyter notebooks
Project description
C3.js and plotly.js charting in ipython/jupyter notebooks
IPlotter is a simple library for generating interactive charts in C3.js or plotly.js from simple python data structures (dictionaries, lists, etc.)
Installation
To install this package run pip install git+git://github.com/niloch/iplotter.git@master or pip install iplotter
C3.js
C3 is a charting library based on d3 for making interactive and easy to understand charts, graphs, and plots.
Charts can be conveniently declared as javascript objects and bound to DOM elements has animated transitions for hiding/displaying data.
plotly.js
Plotly.js is a charting library based on d3 from plotly. plotly provides native clients in many languages including python which can be rendered in an ipython notebook. However, the native python client requires the user to create an account and by default makes all plots public for free accounts. plotly.js can be used without creating an account and the results are rendered locally and kept private. IPlotter makes use of the plotly.js library for chart rendering instead of the native python package from plotly.
Usage
iplotter contains one class called IPlotter which is initialized according to the library that will be used (‘c3/plotly’). An instantiated plotter’s functions are called on supplied data with optional arguments for size and filename if needed. The data should be a python dictionary, with an equivalent structure according the specifications for the chart json objects in either C3.js or plotly.js. plotly.js optionally allows specifying the chart layout as a separate dictionary.
Examples
C3 Stacked Area Spline Chart
from iplotter.iplotter import IPlotter
plotter = IPlotter('c3')
chart = {
"data": {
"columns": [
['data1', 300, 350, 300, 0, 0, 120],
['data2', 130, 100, 140, 200, 150, 50],
['data3', 180, 75, 265, 100, 50, 100]
],
"types": {
"data1": 'area-spline',
"data2": 'area-spline',
"data3": 'area-spline'
},
"groups": [['data1', 'data2', 'data3']]
}
}
plotter.plot(chart)
plotly.js Grouped Bar Chart
from iplotter.iplotter import IPlotter
plotter2 = IPlotter('plotly')
trace1 = {
"x": ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
"y": [20, 14, 25, 16, 18, 22, 19, 15, 12, 16, 14, 17],
"type": 'bar',
"name": 'Item 1',
"marker": {
"color": 'rgb(49,130,189)',
"opacity": 0.7,
}
}
trace2 = {
"x": ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
"y": [19, 14, 22, 14, 16, 19, 15, 14, 10, 12, 12, 16],
"type": 'bar',
"name": 'Item 2',
"marker": {
"opacity": 0.7
}
}
data = [trace1, trace2]
layout = {
"title": 'Title',
"xaxis": {
"tickangle": -45
},
"barmode": 'group'
};
plotter2.plot(data,layout)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for iplotter-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6418807535a5c8be819e94626c0802aa29a7291dc0dd551c024b13eb7c6a3c20 |
|
MD5 | 5c9b0e2d3c6434bb01b27ec25059f09a |
|
BLAKE2b-256 | 507a4f12aee4de624066a1c61936edb15e12ece334426a05aed60215b997bef4 |