为什么我的绘图库不绘制图表

问题描述 投票:0回答:1

我最近一直在Python中使用plotly库(这是我第一次使用它)来绘制比特币的烛台图,但由于某种原因它没有绘制图表并显示“无法访问该站点”。这是代码及其输出!

import pandas as pd
import plotly.graph_objects as go

df = pd.read_csv('Bitstamp_AAVEBTC_d.csv')
df = df.iloc[::-1]
df['date'] = pd.to_datetime(df['date'])
fig = go.Figure(data = [go.Candlestick(x = df['date'],
                        open = df['open'], high = df['high'],
                        low = df['low'], close = df['close'])])
# print(df)
fig.show()


有人可以帮我吗?

python
1个回答
0
投票

当尝试在依赖于基于 Web 的界面的 Jupyter Notebook 等环境中显示 Plotly 图形时,通常会出现此错误消息。您可以使用

plotly.offline
直接在 Jupyter Notebook 或本地环境中渲染绘图,以避免尝试在 Web 浏览器中打开它。操作方法如下:

import pandas as pd
import plotly.graph_objects as go
from plotly.offline import init_notebook_mode, iplot

init_notebook_mode(connected=True)  # Initialize Plotly for offline use

df = pd.read the CSV file('Bitstamp_AAVEBTC_d.csv')
df = df.iloc[::-1]
df['date'] = pd.to_datetime(df['date'])
fig = go.Figure(data=[go.Candlestick(x=df['date'], open=df['open'], high=df['high'], low=df['low'], close=df['close'])])

iplot(fig)  # Display the figure in the Jupyter Notebook
© www.soinside.com 2019 - 2024. All rights reserved.