forked from ukosuagwu/python-nvd3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlineChartXY.py
More file actions
36 lines (28 loc) · 974 Bytes
/
lineChartXY.py
File metadata and controls
36 lines (28 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Examples for Python-nvd3 is a Python wrapper for NVD3 graph library.
NVD3 is an attempt to build re-usable charts and chart components
for d3.js without taking away the power that d3.js gives you.
Project location : https://github.com/areski/python-nvd3
"""
from nvd3 import lineChart
from numpy import sin, pi, linspace
output_file = open('test_lineChartXY.html', 'w')
type = "lineChart"
chart = lineChart(name=type, x_is_date=False,
x_axis_format=".1f", y_axis_format=".1f",
width=500, height=500,
show_legend=False)
# lissajous parameters of a/b
a = [1, 3, 5, 3]
b = [1, 5, 7, 4]
delta = pi / 2
t = linspace(-pi, pi, 300)
for i in range(0, 4):
x = sin(a[i] * t + delta)
y = sin(b[i] * t)
chart.add_serie(y=y, x=x, name='lissajous-n%d' % i, color='red' if i == 0 else 'black')
chart.buildhtml()
output_file.write(chart.htmlcontent)
output_file.close()