Ploting in Jupyter Lab

86 views
Skip to first unread message

Geoffry Roberts

unread,
Nov 26, 2018, 3:03:24 PM11/26/18
to jup...@googlegroups.com
Hi all,

Quick question asking: Is this possible?

I want to create a plot and have it appear in the output cell of Jupiter lab.  

I am using Julia and Plots.jl with the Plotly backend enabled.  My plot works peachy when run from a CL script. However, if I run the same in Jupiter,  a new browser tab is created for each plot but nothing displays.  Tab is empty. No errors show.  Output cell says "false".

Thanks

--
There are ways and there are ways, 

Geoffry Roberts

Oliver Frank

unread,
Jan 9, 2019, 4:21:33 PM1/9/19
to Project Jupyter
Hi Geoffry,

is it possible that you use another Environment? I had the same Problem. On the commandline the configfile .plotly/.credentials was used anderen under juyter another configfile was used.

Oliver Frank

unread,
Jan 9, 2019, 4:31:11 PM1/9/19
to Project Jupyter
Hi Geoffry,

an example which works for me in jupyter lab.

------------------------------------------------------------------------

import plotly.plotly as py
from plotly import tools
import plotly.offline as offline
import plotly.graph_objs as go


import pandas as pd
from datetime import datetime

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')[1:20]

# Date,AAPL.Open,AAPL.High,AAPL.Low,AAPL.Close,AAPL.Volume,AAPL.Adjusted,
# dn,mavg,up,direction

#print(df['AAPL.High'])
#print(df.Date)

trace1 = go.Scatter(name="AAPL.Open", x=df.Date, y=df['AAPL.Open'])
trace2 = go.Scatter(name="AAPL.Low",  x=df.Date, y=df['AAPL.Low'])
trace3 = go.Scatter(name="AAPL.High", x=df.Date, y=df['AAPL.High'])
trace4 = go.Scatter(name="dn", x=df.Date, y=df['dn'])
trace5 = go.Scatter(name="mavg", x=df.Date, y=df['mavg'])
trace6 = go.Scatter(name="direction", x=df.Date, y=df['direction'])

layout = go.Layout(
    xaxis=dict(
        title='X-AXIS TITLE',       
        autorange=True,
        showgrid=False,
        zeroline=False,
        showline=False,
        ticks='',
        showticklabels=False
    ),
    yaxis=dict(
        title='Y-AXIS TITLE',       
        autorange=True,
        showgrid=False,
        zeroline=False,
        showline=False,
        ticks='',
        showticklabels=False
    )
)

fig = tools.make_subplots(rows=3, cols=2, subplot_titles=('AAPL.Open',
                                                          'AAPL.Low',
                                                          'AAPL.High',
                                                          'dn',
                                                          'mavg',
                                                          'direction',
                                                         )
                         )

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 2)
fig.append_trace(trace3, 2, 1)
fig.append_trace(trace4, 2, 2)
fig.append_trace(trace5, 3, 1)
fig.append_trace(trace6, 3, 2)


fig['layout'].update(layout)

# Result in a jupyter cell
py.iplot(fig, filename='make-subplots-multiple-with-titles')

# Result in an new Tab
# offline.plot(data, filename='time-series-simple.html')

------------------------------------------------------------------------

Oliver

Geoffry Roberts

unread,
Jan 9, 2019, 5:37:01 PM1/9/19
to jup...@googlegroups.com
Thanks Oliver.

Since I posted, I got it to work.  I am using Julia.

using Plots
plotlyjs()
# Aedge is an associative array.  Aedge.A is it's internal array.
scatter(Aedge.A, layout = 1, markersize=Aedge.A, marker=:hex, c=:red, fmt = :svg) 

--
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 jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/4d0d1b5b-411c-4763-9760-e7522145416a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages