Skip to content

Instantly share code, notes, and snippets.

@arduanov
Created May 19, 2017 12:44
Show Gist options
  • Save arduanov/1ed5518b5bb0dc9eb7df2b632596aac3 to your computer and use it in GitHub Desktop.
Save arduanov/1ed5518b5bb0dc9eb7df2b632596aac3 to your computer and use it in GitHub Desktop.
pyspark matplotlib
%pyspark
import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import StringIO
import pandas as pd
import os
import matplotlib
matplotlib.use('Agg')
os.system("export DISPLAY=:0")
def show(p):
img = StringIO.StringIO()
p.savefig(img, format='svg')
img.seek(0)
print "%html <div style='width:1600px'>" + img.buf + "</div>"
# Example data
p = plt.figure(figsize=(10, 10))
pd.Series([i ** 2 for i in range(10)]).plot()
pd.Series([i ** 3 for i in range(10)]).plot()
show(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment