简体   繁体   English

无法在 Jupyter Notebook 上使用 Plotly

[英]Unable to use Plotly on Jupyter Notebook

I have written a piece of code to generate a plot using Plotly in JupyterLab.我已经编写了一段代码,在 JupyterLab 中使用 Plotly 生成一个 plot。 The code is running just fine but I'm unable to view the graph代码运行正常,但我无法查看图表

import plotly.graph_objects as go

data = [
    go.Candlestick(
        x = Data365.index,
        low = Data365['Low'],
        high = Data365['High'],
        open = Data365['Open'],
        close = Data365['Close'],
        increasing_line_color = 'green',
        decreasing_line_color = 'red'
    )
]

figure.update_layout(xaxis_rangeslider_visible=False,title = 'Daily OHLC for the last 1 Year', yaxis_title = 'Price in USD', xaxis_title = 'Date') 

figure.show()

Plotly Version: 4.10.0 Plotly 版本:4.10.0

Upgrading plotly might be your best bet here.升级plotly可能是您最好的选择。

With plotly==5.6.0 the candlestick chart example from the plotly documentation worked in JupyterLab.使用plotly==5.6.0 ,来自 plotly 文档的烛台图表示例在 JupyterLab 中工作。

Code:代码:

import plotly.graph_objects as go
import pandas as pd

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

JupyterLab output:朱庇特实验室 output:

来自 JupyterLab 的屏幕截图,上半部分显示 Python 代码,下半部分显示运行代码生成的烛台图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM