[SOLVED] How to plot in jupyter qtconsole

OS X
Jupyter QtConsole 4.4.3
Python 3.7.1 (default, Dec 14 2018, 13:28:58)
IPython 7.2.0 – An enhanced Interactive Python. Type ‘?’ for help.

Can plot matplotlib graphs

But when trying plotly, there is no output in the console

If I use go.Figure, I get a Warning message as below:

The offline plotting in the browser works. But I would really like to use the Jupyter console if possible. It’s supposed to work is it not?

Hi @awsm,

There’s nothing built-in for this yet (I hope to change this before too long), but here’s a way to do it today. Install orca (https://plot.ly/python/static-image-export/), and then define this utility function

from IPython.display import display, Image
import plotly.io as pio

def show(fig):
    display(Image(pio.to_image(fig, format='png')))

Then…

Note that the very first time you show a figure it will take a few seconds for the orca server to start up. But after that, image display should be about as fast as matplotlib. https://medium.com/@plotlygraphs/plotly-py-end-of-summer-updates-5422c98b9058

Hope that helps, and let us know how it goes!

-Jon

@jmmease
Sweeet!! Thank you, it works!

By the way, how did you get rid of the scroll bars on the qtconsole window?

1 Like

Awesome!

I think my scrollbars are hidden because I’m on MacOS, which hides the scroll bars unless you are scrolling. The same thing happens in most other MacOS applications.

-Jon

I see. Thank you. It’s too bad there isn’t a way to disable scrollbars like a regular Terminal.

Updating this old thread for better SEO, and to reflect improvements in platform.

# make sure your qtconsole magic is set.
%matplotlib inline

# qtconsole knows how to inline `.png` files already.
import plotly.graph_objects as pio
pio.renderers.default = 'png'.     


# test functionality
import plotly.graph_obs as go
fig = go.Figure()
fig

fig.show()
1 Like