python - 绘图不显示
问题描述
我只是在尝试绘图/破折号,当我编写下面的代码时,什么都没有显示.. 它只是一个空白框。我已经尝试安装nodejs(我正在使用anaconda),以便我可以尝试安装一些扩展程序'jupyter labextension install @jupyterlab/plotly-extension',但这由于某种原因我什至无法安装nodejs。
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.offline as pyo
import plotly.graph_objs as go
# Set notebook mode to work in offline
pyo.init_notebook_mode()
#init_notebook_mode(connected=True)
# Create traces
trace0 = go.Scatter(
x=[1, 2, 3, 4],
y=[10, 15, 13, 17]
)
trace1 = go.Scatter(
x=[1, 2, 3, 4],
y=[16, 5, 11, 9]
)
# Fill out data with our traces
data = [trace0, trace1]
layout=go.Layout(barmode='stack')
fig=go.Figure(data=data, layout=layout)
# Plot it and save as basic-line.html
pyo.iplot(fig, filename = 'basic-line')
我还能做些什么来帮助查看我的图表?
解决方案
我想要更多关于 polty、Jupyterlab 等版本的信息,但iplot()
很可能是这里的问题。尝试另一个基本示例,例如:
代码:
import plotly.graph_objects as go
animals=['giraffes', 'orangutans', 'monkeys']
fig = go.Figure(data=[
go.Bar(name='SF Zoo', x=animals, y=[20, 14, 23]),
go.Bar(name='LA Zoo', x=animals, y=[12, 18, 29])
])
# Change the bar mode
fig.update_layout(barmode='stack')
fig.show()
阴谋:
让我知道这对你有什么影响。
推荐阅读
- django - 使用带有 JSON 的文本字段而不是 ForeignKey 关系?
- android - 使用 setMultiChoiceModeListener 在 Listview 中链接 textView 不起作用?
- c# - DryIoc - 注入带有附加参数的 Func 作为工厂方法
- php - 如何以安全的方式使用应用程序的 GUI 将 API 密钥保存到 .env?
- python - 我可以从 Python 中的 csv 随机打印行吗?
- php - 如何访问 Laravel 刀片中的请求参数?
- azure - 用于矢量 PDF 的 Azure 读取 API
- google-cloud-platform - 将带有问号的 GCS 存储桶 blob 下载到文件中
- python - 实现 Ray.Tune PBT 超参数优化时的数据集枚举(epoch 和 batchSize)
- python - 未检测到css文件时的Python异常以及如何检测css文件