Created
May 19, 2017 12:44
-
-
Save arduanov/1ed5518b5bb0dc9eb7df2b632596aac3 to your computer and use it in GitHub Desktop.
pyspark matplotlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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