I try to find how jupyter display inline image of matplotlib, but could not 
find where jupyter use output_hook


在 2017年7月10日星期一 UTC+8下午10:17:13,Jeff Zhang写道:
>
>
> Thanks Thomas, is there any sample code that I can refer ?
>
>
> 在 2017年7月10日星期一 UTC+8下午3:56:27,takowl写道:
>>
>> Hi Jeff,
>>
>> I think the output_hook parameter to execute_interactive() is what you 
>> want. Here's the docs:
>>
>> http://jupyter-client.readthedocs.io/en/latest/api/client.html#jupyter_client.BlockingKernelClient.execute_interactive
>>
>> Thomas
>>
>>
>> On 9 July 2017 at 13:37, Jeff Zhang <[email protected]> wrote:
>>
>>>
>>> I try to use jupyter_client to get the matplotlib output and display it 
>>> in my app. Here's what I did. But io.stdout is just a string. How can I get 
>>> the actual image data of matplotlib. Thanks
>>>
>>>
>>> In [6]: with capture_output() as io:
>>>    ...:     reply = kc.execute_interactive("import matplotlib.pyplot as 
>>> plt\n%matplotlib inline\ndata=[1,1,2,3,4]\nplt.figure()\nplt.plot(data)", 
>>> timeout=TI
>>>    ...: MEOUT)
>>>    ...:
>>>    ...:
>>>
>>> In [8]: io.stdout
>>> Out[8]: '[<matplotlib.lines.Line2D at 
>>> 0x1086a8d30>]<matplotlib.figure.Figure at 0x106f220f0>'
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Project Jupyter" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/jupyter/3332cdec-b938-495e-821a-86132ac31749%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jupyter/3332cdec-b938-495e-821a-86132ac31749%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/715e5b28-77b0-40bf-93b3-6301e4567990%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to