Created
July 1, 2015 07:42
-
-
Save andershammar/9070e0f6916a0fbda7a5 to your computer and use it in GitHub Desktop.
Example showing how to use matplotlib from a Zeppelin notebook
This file contains 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 StringIO | |
def show(p): | |
img = StringIO.StringIO() | |
p.savefig(img, format='svg') | |
img.seek(0) | |
print "%html <div style='width:600px'>" + img.buf + "</div>" | |
# Example data | |
people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim') | |
y_pos = np.arange(len(people)) | |
performance = 3 + 10 * np.random.rand(len(people)) | |
error = np.random.rand(len(people)) | |
plt.barh(y_pos, performance, xerr=error, align='center', alpha=0.4) | |
plt.yticks(y_pos, people) | |
plt.xlabel('Performance') | |
plt.title('How fast do you want to go today?') | |
show(plt) |
awesome, saved a lot of time! Thanks!
Try
z.showplot(plt)
or
z.showmatplot(plt)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Smashing, thank you very much!