Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Candlestick chart does not show with plotly

Probably something really simple.

I use an example to plot a Candlestick chart using plotly, but the plot never show up!?

This is the code from https://plot.ly/python/candlestick-charts/

import plotly.graph_objects 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')

fig = go.Figure(data=[go.Candlestick(x=df['Date'],
                open=df['AAPL.Open'],
                high=df['AAPL.High'],
                low=df['AAPL.Low'],
                close=df['AAPL.Close'])])

fig.show()

I'm using last updated python and spyder4 on anaconda. I usually use matplotlib without problem.

like image 491
Jonathan Roy Avatar asked Dec 05 '25 20:12

Jonathan Roy


1 Answers

It is an issue already considered in the plotly community:

import plotly.graph_objects as go
from plotly.offline import iplot
import pandas as pd
from datetime import datetime

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

fig = go.Figure(data=[go.Candlestick(x=df['Date'],
                open=df['AAPL.Open'],
                high=df['AAPL.High'],
                low=df['AAPL.Low'],
                close=df['AAPL.Close'])])

iplot(fig)
like image 150
sentence Avatar answered Dec 08 '25 11:12

sentence



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!