Tutorials

Plot three series

See the output at http://blacksburg98.github.io/dyplot/html/tutorial1.html

import pandas as pd
from dyplot.dygraphs import Dygraphs
a = pd.Series([1,2,3,4,5,6,7,9,10])
b = pd.Series([1,3,5,9,2,8,5,5,15])
lc= pd.Series([1,3,4,5,6,7,9,3,2])
c = pd.Series([2,4,5,7,8,8,9,4,3])
hc= pd.Series([3,5,7,7,9,11,9,5,8])
dg = Dygraphs(a.index, "index")
dg.plot(series="a", mseries=a)
dg.plot(series="b", mseries=b)
dg.plot(series="c", mseries=c,lseries=lc, hseries=hc)
dg.set_options(title="Test")
dg.set_axis_options(axis="x",axisLabelColor="red")
div = dg.savefig(csv_file="tutorial1.csv", html_file="tutorial1.html")

Pie Chart

See the output at http://blacksburg98.github.io/dyplot/html/c3_pie.html

from dyplot.pie import Pie
frac = [30, 20, 50]
labels = ["setosa", "versicolor", "viginica"]
g = Pie(frac=frac, labels=labels)
c = {}
c["columns"] = []
c["columns"].append(["setosa", 100])
g.animate("load", c, 1000)
g.savefig(html_file="c3_pie.html")

Bar Chart

See the output at http://blacksburg98.github.io/dyplot/html/c3_bar.html

from dyplot.bar import Bar
h = [30, 20, 50, 40]
label = "setosa"
g = Bar(height=h, label=label)
h2 = [50, 30, 20, 30]
label2 = "barora"
h3 = [40, 20, 10, 50]
label3 = "exama"
g = Bar(height=h, label=label)
g(height=h2, label=label2)
g(height=h3, label=label3)
g.set_xticklabels(["G1", "G2", "G3", "G4"], "category")
g.savefig(html_file="c3_bar.html")

Histogram

See the output at http://blacksburg98.github.io/dyplot/html/c3_hist.html

from dyplot.hist import Hist
a = [3,4,4,5,6,6,6,6,5,9,3,3,4,4,5,6,7,8,9,3,2,2,4,5]
g = Hist(a, xlabel="Frequency")
g.savefig(html_file="c3_hist.html")

Scatter Plot

See the output at http://blacksburg98.github.io/dyplot/html/nvd3_scatter.html

import numpy as np
import csv
from dyplot.scatter import Scatter
if __name__ == '__main__':
    x = np.random.rand(20)
    y = np.random.rand(20)
    s = Scatter(x, y, "Group 1", s=2, slope=-1, intercept=0.9)
    x = np.random.rand(10)
    y = np.random.rand(10)
    s(x, y, "Group 2", marker="+", s=[1,3,2,4,5,6,6,5,4,3], slope=1, intercept=0.1)
    x = np.random.rand(10)
    y = np.random.rand(10)
    s(x, y, "Group 3", s=2, marker=["^", 'v', 'o', '+', 's', 's', 's', 'D', 'D', 'v'])
    s.savefig(csv_file="../gh-pages/html/nvd3_scatter.csv",html_file="../gh-pages/html/nvd3_scatter.html"
        ,csv_url="nvd3_scatter.csv")