fig.show() doesn't show the plot when using Candlestick

70 views Asked by At

I have trouble to show the candlestick plot. I have tried fig.show() and iplot(fig) but they return a white screen! and when I try plt.plot(fig) I get TypeError: unhashable type: 'Figure'. here is the code:

import plotly.graph_objects as go

candlestick_data = data.groupby(data.Date.dt.date).agg({'Price':['min','max','first'
                                                           ,'last']})

fig = go.Figure(data=[go.Candlestick(x = candlestick_data.index,
                                    open=candlestick_data['Price']['first'],
                                    high=candlestick_data['Price']['max'],
                                    low=candlestick_data['Price']['min'],
                                    close=candlestick_data['Price']['last'])
                     ])
fig.update_layout(xaxis_rangeslider_visible=False, xaxis_title='Date',
                 yaxis_title='Price(USD$)', title='Bitcoin Candlestick Chart Over Past 30 Days')

fig.show() #returns white screen

this is how candlestick_data looks like:

candlestick_data

1

There are 1 answers

0
Sepid On

I am working in jupyter and based on suggestion provided here I changed the notebook mode. So here is what I added to make it work for me:

import plotly.offline as pyo
# Set notebook mode to work in offline
pyo.init_notebook_mode()