In [35]:
# Import pydygraphs and numpy
import sys
sys.path.append("../")

import dygraphs.graph as dy
import numpy as np

In [42]:
# Single Figure Example
fig = dy.figure(width=800)

# Form data for plot
size = 100
x = np.array(range(size))
y = [np.sin(np.random.rand(size)),-np.sin(np.random.rand(size)), np.random.rand(size)]
y = np.array(y)
# Plot figure
options = {'labels': 'these are the labels'.split(' '), 'fillGraph': True, 'fillAlpha': 0.6,
          'colors': 'red orange teal'.split(' ')}
fig.plot(x,y, **options)
fig.title('Plot Title')
fig.xlabel('X Axis')
fig.ylabel('Y Axis')

# Show figure:
fig.show()



In [37]:
# Subplot example
[fig1],[fig2] = dy.subplot(2,1, title="PyDyGraphs Example Subplot")

# Form data for plot 1
size = 4000
x = np.array(range(size))
y1 = [np.sin(np.array(range(size)) * np.pi / 180.), np.sin(np.array(range(size)) * np.pi / 360)]

# Plot figure 1
fig1.plot(x,y1, labels='label1 label2 label3'.split(' '), fillGraph=True, fillAlpha=0.4)
fig1.title("Figure 1")
fig1.xlabel('Series')
fig1.ylabel('Value')

# Form data for plot 2
y2 = [np.sin(np.random.rand(size))]

# Plot figure 2
fig2.plot(x, y2, labels=["x_var", "Random Variable"], color=['orange'], showRangeSelector=True, showRoller=False)
fig2.title("Figure 2")
fig2.xlabel('Series')
fig2.ylabel('Value')

# Show plots:
fig1.show()
fig2.show()


PyDyGraphs Example Subplot


In [41]:
## Dataframe example
import pandas as pd
import numpy as np

# Form a dataframe
df = pd.DataFrame(columns=['a', 'label1', 'label2'])
df.a=np.arange(0, 1000)
df.label1=np.sin(df.a*0.02*np.pi/10) + (np.random.ranf(size=len(df.a))-0.5)*0.25
df.label2=np.cos(df.a*np.pi/5)

# Create a plot directly from a Pandas dataframe
fig3 = dy.figure()

options = {'stepPlot': True, 'colors': 'green blue'.split(' ')}
fig3.plotDataFrame(df, **options)
fig3.title('Plot Title 3')

# fig3.xlabel('a');fig3.ylabel('Units of Awesome');fig3.title('Dataframe Example')
fig3.show()



In [15]:
print (dy.__PYDYGRAPH__DYGRAPHS_LIB_STRING__)


http://dygraphs.com/dygraph-combined.js

In [ ]: