You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@zeppelin.apache.org by Abhi Basu <90...@gmail.com> on 2016/02/09 20:34:19 UTC
Plotting error
Using Zeppelin 0.5.6
%pyspark
import matplotlib.pyplot as plt
# Test data
x = [1, 2, 3, 4, 5, 6, 7, 8]
y = [20, 21, 20.5, 20.81, 21.0, 21.48, 22.0, 21.89]
# Plot
plt.plot(x, y, linestyle='dashed', marker='o', color='red')
show(plt)
Traceback (most recent call last): File "/tmp/zeppelin_pyspark.py", line
225, in <module> eval(compiledCode) File "<string>", line 5, in <module>
NameError: name 'show' is not defined
The code executes fine, but the show command gives the error. How to fix
this?
Thanks,
Abhi
--
Abhi Basu
Re: Plotting error
Posted by Abhi Basu <90...@gmail.com>.
Awesome, that works.
Thanks,
Abhi
On Tue, Feb 9, 2016 at 4:04 PM, moon soo Lee <mo...@apache.org> wrote:
> Hi Abhi,
>
> You'll need to define show(). Such as
>
> %pyspark
> import StringIO
> def show(p):
> img = StringIO.StringIO()
> p.savefig(img, format='svg')
> img.seek(0)
> print "%html " + img.buf
>
>
> Hope this helps.
>
> Best,
> moon
>
> On Wed, Feb 10, 2016 at 4:34 AM Abhi Basu <90...@gmail.com> wrote:
>
>> Using Zeppelin 0.5.6
>>
>> %pyspark
>> import matplotlib.pyplot as plt
>>
>> # Test data
>> x = [1, 2, 3, 4, 5, 6, 7, 8]
>> y = [20, 21, 20.5, 20.81, 21.0, 21.48, 22.0, 21.89]
>>
>> # Plot
>> plt.plot(x, y, linestyle='dashed', marker='o', color='red')
>> show(plt)
>>
>>
>>
>> Traceback (most recent call last): File "/tmp/zeppelin_pyspark.py", line
>> 225, in <module> eval(compiledCode) File "<string>", line 5, in <module>
>> NameError: name 'show' is not defined
>>
>>
>> The code executes fine, but the show command gives the error. How to fix
>> this?
>>
>> Thanks,
>>
>> Abhi
>>
>> --
>> Abhi Basu
>>
>
--
Abhi Basu
Re: Plotting error
Posted by moon soo Lee <mo...@apache.org>.
Hi Abhi,
You'll need to define show(). Such as
%pyspark
import StringIO
def show(p):
img = StringIO.StringIO()
p.savefig(img, format='svg')
img.seek(0)
print "%html " + img.buf
Hope this helps.
Best,
moon
On Wed, Feb 10, 2016 at 4:34 AM Abhi Basu <90...@gmail.com> wrote:
> Using Zeppelin 0.5.6
>
> %pyspark
> import matplotlib.pyplot as plt
>
> # Test data
> x = [1, 2, 3, 4, 5, 6, 7, 8]
> y = [20, 21, 20.5, 20.81, 21.0, 21.48, 22.0, 21.89]
>
> # Plot
> plt.plot(x, y, linestyle='dashed', marker='o', color='red')
> show(plt)
>
>
>
> Traceback (most recent call last): File "/tmp/zeppelin_pyspark.py", line
> 225, in <module> eval(compiledCode) File "<string>", line 5, in <module>
> NameError: name 'show' is not defined
>
>
> The code executes fine, but the show command gives the error. How to fix
> this?
>
> Thanks,
>
> Abhi
>
> --
> Abhi Basu
>