标签: plotly-dash

运行 docker 时无法将“app.server”解析为属性名称或函数调用

我正在尝试从 docker 运行我的应用程序,但我收到了来自docker logs破折号的错误消息。我搜索了很多但找不到任何东西。请帮忙!

docker logs来自破折号图像的日志消息

[2020-08-22 06:44:32 +0000] [1] [INFO] Starting gunicorn 20.0.4
[2020-08-22 06:44:32 +0000] [1] [INFO] Listening at: http://0.0.0.0:8050 (1)
[2020-08-22 06:44:32 +0000] [1] [INFO] Using worker: sync
[2020-08-22 06:44:32 +0000] [8] [INFO] Booting worker with pid: 8
Failed to parse 'app.server' as an attribute name or function call.
[2020-08-22 06:44:33 +0000] [8] [INFO] Worker exiting (pid: 8)
[2020-08-22 06:44:33 +0000] [1] [INFO] Shutting down: Master
[2020-08-22 06:44:33 +0000] [1] [INFO] Reason: App failed …
Run Code Online (Sandbox Code Playgroud)

python docker dockerfile docker-compose plotly-dash

6
推荐指数
2
解决办法
6827
查看次数

Plotly 图例在手机上无法缩放

我正在使用 Dash 绘制一个情节。当我在桌面上查看它时,看起来不错 桌面

但是当我在手机上查看它时,图例位置与图表重叠。 电话

我的传奇是使用设置的

legend=dict(
    bgcolor='rgba(0,0,0,0)',
    orientation="h",
    yanchor="bottom",
    y=-0.15,
    xanchor="left",
    x=0
)
Run Code Online (Sandbox Code Playgroud)

如何修复图例?额外问题,如何修复模式栏?

python plotly plotly-dash

6
推荐指数
1
解决办法
515
查看次数

如何在plotly中将时间线图与散点图结合起来

我有一个数据框df,其中包含随时间变化的值(过程数据)。我有一个数据框ef,其中包含具有开始时间和结束时间的事件(警报)。我想以一种美观的方式将它们组合在一个情节中。

"""
df==
+---------------------+------------+------------+------------+
|                     |   processA |   processB |   processC |
|---------------------+------------+------------+------------|
| 2020-01-01 00:00:00 |    101.764 |   20.0079  |   0.978738 |
| 2020-01-01 00:01:00 |    102.241 |   93.3779  |  -0.977278 |
| 2020-01-01 00:02:00 |    100.95  |   -7.56786 |  -0.103219 |
| 2020-01-01 00:03:00 |    100.411 |    7.20218 |   1.45427  |
| 2020-01-01 00:04:00 |    100.761 |    6.08375 |   0.443863 |
+---------------------+------------+------------+------------+

ef==
+----+-----------------------------------------+---------------------+---------------------+----------+
|    | alm                                     | Start               | Finish              | almid    | …
Run Code Online (Sandbox Code Playgroud)

python pandas plotly plotly-dash

6
推荐指数
1
解决办法
1490
查看次数

Python Dash 独立 HTML 文件与 Plotly 相同

我通常使用 Plotly 绘图并将它们保存为独立的 HTML 文件,这对于与同事共享和“冻结”正在显示的数据非常方便。是我用的一个例子

\n
plotly.offline.plot(\n    plotly_plot, \n    filename = \'standalone great plot.html\',\n)\n
Run Code Online (Sandbox Code Playgroud)\n

现在我想用一个非常简单的 Dash 应用程序做同样的事情,它根本没有服务器端要求,它只是一堆 Plotly 图形和一些文本。我怎样才能做到这一点?

\n

我想要的例子

\n

考虑本教程中显示的第一个示例,为了方便起见,我将其复制粘贴到此处:

\n
# -*- coding: utf-8 -*-\n\n# Run this app with `python app.py` and\n# visit http://127.0.0.1:8050/ in your web browser.\n\nimport dash\nimport dash_core_components as dcc\nimport dash_html_components as html\nimport plotly.express as px\nimport pandas as pd\n\nexternal_stylesheets = [\'https://codepen.io/chriddyp/pen/bWLwgP.css\']\n\napp = dash.Dash(__name__, external_stylesheets=external_stylesheets)\n\n# assume you have a "long-form" data frame\n# see https://plotly.com/python/px-arguments/ for more options\ndf = pd.DataFrame({\n    "Fruit": …
Run Code Online (Sandbox Code Playgroud)

html python plotly plotly-dash

6
推荐指数
1
解决办法
6110
查看次数

有人尝试过使用 Dash Plotly 制作移动应用程序吗?

有人尝试过使用 Dash 制作移动应用吗?

\n

我发现在手机上浏览 Dash 页面非常有用,但我不想每次都输入 URL 并登录。

\n

而如果它\xe2\x80\x99是一个移动应用程序,无论是嵌入式还是本机,都有更多可以实现的功能。

\n

mobile plotly plotly-dash

6
推荐指数
1
解决办法
5103
查看次数

python中的点击事件plotly-dash散点图

我想创建两个包含 iframed 虚线图的网页。我想实现第一个图表的点击事件以重定向到另一个页面(包含有关该特定数据的更多信息)

我遵循了指南,但即使我将 ipywidgets、node.js 和plotlywidgets 扩展安装到我正在运行的 python venv 中,我的设置中也不会触发单击事件。上面的示例中有一条注释:

注意:只有当跟踪属于plotly.graph_objs.FigureWidget 的实例并且它显示在ipywidget 上下文中时才会触发回调。使用plot/iplot 显示的图形不会触发回调。

该示例使用的是FigureWidget,我通过将数字传递到dcc.Graph应与 相同的方式来绘制它fig.show()。整个代码看起来像这样

import plotly.graph_objects as go
import numpy as np
np.random.seed(1)

x = np.random.rand(100)
y = np.random.rand(100)

fig = go.FigureWidget([go.Scatter(x=x, y=y, mode='markers')])

scatter = fig.data[0]
colors = ['#a3a7e4'] * 100
scatter.marker.color = colors
scatter.marker.size = [10] * 100
fig.layout.hovermode = 'closest'


# create our callback function
def update_point(trace, points, selector):
    c = list(scatter.marker.color)
    s = list(scatter.marker.size)
    for …
Run Code Online (Sandbox Code Playgroud)

python onclick ipywidgets plotly-dash

6
推荐指数
1
解决办法
7948
查看次数

如何为 Plotly Dash 回调函数编写测试用例?

我正在尝试在页面中为 Dash 回调函数编写一个测试用例,该页面将 2 个数据表的选定行存储到dash_core_components.Store,并通过以下方式确定状态dash.callback_context

示例回调函数在index.py

@app.callback(
    Output('rows-store', 'data'),
    Input('datatable1', 'selected_rows'),
    Input('datatable2', 'selected_rows'),
)
def store_row_selection(row1: list, row2: list) -> dict:
    ctx = dash.callback_context
    if not ctx.triggered:
        return {'row-index-v1': [0], 'row-index-v2': [0]}
    else:
        return {'row-index-v1': row1, 'row-index-v2': row2}
Run Code Online (Sandbox Code Playgroud)

示例测试用例位于test.py

def test_store_row_selection_1(app_datatable):
    r1 = [0]
    r2 = [1]
    result = store_row_selection(r1, r2)

    assert type(result) is dict  
Run Code Online (Sandbox Code Playgroud)

但是,Pytest 在运行时抛出异常,测试回调函数的正确方法是什么以及如何让它工作?

  @wraps(func)
    def add_context(*args, **kwargs):
>       output_spec = kwargs.pop("outputs_list")
E       KeyError: 'outputs_list'
Run Code Online (Sandbox Code Playgroud)

python pytest plotly-dash

6
推荐指数
1
解决办法
2764
查看次数

Python Dash:向 DIV 添加滚动条

我希望将滚动条添加到 Dash 应用程序的侧栏面板 - 请参阅此应用程序作为示例。当内容跑出页面时,我可以让滚动条动态显示,但我似乎可以让主页 div 显示在侧边栏 div 右侧的唯一方法是设置 CSS style "position": "fixed"。但是,即使滚动条可用,该设置也会将内容固定在适当的位置。在此输入图像描述

这是代码:

import dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])

# the style arguments for the sidebar. We use position:fixed and a fixed width
SIDEBAR_STYLE = {
    "position": "fixed",
    "top": 0,
    "left": 0,
    "bottom": 0,
    "width": "16rem",
    "padding": "2rem 1rem",
    "background-color": "#f8f9fa",
}

# the styles for the main content position …
Run Code Online (Sandbox Code Playgroud)

python plotly-dash

6
推荐指数
1
解决办法
9324
查看次数

可以自动滚动的仪表板

我想知道是否有一种方法可以让破折号表在滚动条可用时自动上下垂直滚动。

这是一个简单的示例(我使用相同的数据帧 7 次以使其足够长)。

import dash
import dash_table
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/solar.csv')
long_data = pd.concat([df,df,df,df,df,df,df])

app = dash.Dash(__name__)

app.layout = dash_table.DataTable(
    id='table',
    columns=[{"name": i, "id": i} for i in long_data.columns],
    data=long_data.to_dict('records'),
)

if __name__ == '__main__':
    app.run_server(debug=False)
Run Code Online (Sandbox Code Playgroud)

有没有办法让这个页面上的内容垂直向上和向下?

html python plotly plotly-dash

5
推荐指数
1
解决办法
1万
查看次数

Plotly:次要 y 轴导致右侧出现空白

我正在制作一个折线图,其中包含大量在超高分辨率下运行的数据。在添加第二个 y 轴时,我发现,plotly svg 组件内的图表右侧会出现一个空白区域。当我关闭第二个轴时,那个空白空间就会消失。当图表在整个屏幕上最大化时,可以清楚地看到。

作为展示,我使用了plotly文档中的一个例子:

from plotly.subplots import make_subplots
import plotly.graph_objects as go

# Create figure with secondary y-axis
fig = make_subplots(specs=[[{"secondary_y": True}]])

# Add traces
fig.add_trace(
    go.Scatter(x=[1, 2, 3], y=[40, 50, 60], name="yaxis data"),
    secondary_y=False,
)

fig.add_trace(
    go.Scatter(x=[2, 3, 4], y=[4, 5, 6], name="yaxis2 data"),
    secondary_y=True,
)

# Add figure title
fig.update_layout(
    title="Right margin",
    showlegend=False
)

# Set x-axis title
fig.update_xaxes(title_text="xaxis title")

# Set y-axes titles
fig.update_yaxes(title_text="<b>primary</b> yaxis title", secondary_y=False)
fig.update_yaxes(title_text="<b>secondary</b> yaxis title", secondary_y=True)

fig.show()
Run Code Online (Sandbox Code Playgroud)

它产生以下图表,不再居中:

右侧空空间

我怎样才能摆脱那个空白空间?

plotly plotly-dash

5
推荐指数
1
解决办法
1071
查看次数