Skip to content

Instantly share code, notes, and snippets.

@Orbifold
Created November 17, 2016 07:08
Show Gist options
  • Save Orbifold/6c92e0e00a00a03fdee41edfcded8122 to your computer and use it in GitHub Desktop.
Save Orbifold/6c92e0e00a00a03fdee41edfcded8122 to your computer and use it in GitHub Desktop.
Zeppelin plotly example.
# if needed, install plotly via shell like so
%sh pip install plotly
#---
%pyspark
import plotly
import numpy as np
from plotly.graph_objs import Scatter, Layout
def plot(plot_dic, height=500, width=1500, **kwargs):
kwargs['output_type'] = 'div'
plot_str = plotly.offline.plot(plot_dic, **kwargs)
print('%%angular <div style="height: %ipx; width: %spx"> %s </div>' % (height, width, plot_str))
plot({
"data": [
Scatter(x=np.arange(1,100), y=np.random.randint(1,100,100))
],
"layout": Layout(
title=Random data"
)
})
@Orbifold
Copy link
Author

A good Zeppelin container can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment