在 Anaconda3 5.0.0 中安装 Plot.ly Dash

13 篇文章 0 订阅
2 篇文章 0 订阅

在 Anaconda3 5.0.0 中安装 Plot.ly Dash

安装包

plotly包可以直接在 Anaconda3 5.0.0 中安装

在Anaconda3 5.0.0 中安装 plotly 包

Anaconda3 5.0.0 中不包含 Dash 相关包,需要进入 Anaconda Prompt命令行安装。

pip install dash==0.19.0
pip install dash-renderer==0.11.1
pip install dash-html-components==0.8.0
pip install dash-core-components==0.14.0

如果出错,也可以不指定版本。

pip install dash
pip install dash-renderer
pip install dash-html-components
pip install dash-core-components

祖传祈福代码,因为是 Web 服务,有点长

# -*- coding: utf-8 -*-
import dash
import dash_core_components
import dash_html_components
import numpy

t = numpy.linspace(0, 2 * numpy.pi, 100)
x = 10 * (2 * numpy.sin(t) - numpy.sin(2 * t))
y = 10 * (2 * numpy.cos(t) - numpy.cos(2 * t))

app = dash.Dash()

app.layout = dash_html_components.Div(children=[
    dash_html_components.H1(children='Hello! Dash love you! '),

    dash_core_components.Graph(
        id='heart-curve',
        figure={
            'data': [
                {'x': x, 'y': y, 'type': 'Scatter', 'name': 'Heart'},
            ],
            'layout': {
                'title': 'Heart Curve'
            }
        }
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)

运行 Web 服务。

C:\ProgramData\Anaconda3\python.exe "C:\Users\huzh\OneDrive\Python\plotly Dash\Hello Dash\Hello Dash.py"

Web 服务启动将显示。

 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 267-618-125
 * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)

按照信息访问 http://127.0.0.1:8050/ 可以看到如图所示。

访问页面

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值