标签: plotly-dash

5
推荐指数
0
解决办法
700
查看次数

如何从可编辑表格更新绘图/虚线图?

我有一个带有可删除行和列的破折号 DataTable 对象。我想根据可见行更新数字。我不确定如何创建回调以及要传递哪些参数。当在浏览器中删除行时,存储在表对象中的数据实际上可能不会改变。

from dash_table import DataTable

def lineplot(id, df, cols, title=None, xlabel=None, ylabel=None, x=None, 
             xaxis_type=None, yaxis_type=None, plotly_config=plotly_config,
            ):

    if x is None:
        x_values = df.index
        xlabel = df.index.name
    else:
        x_values = df[x]

    data = [{
        'x': x_values,
        'y': df[col],
        'name': col }  for col in cols]

    layout = go.Layout(
        title=go.layout.Title(
            text=title,
            xref='paper',
            xanchor='center'
        ),
        xaxis = go.layout.XAxis(
            title=go.layout.xaxis.Title(
                text=xlabel,
                font=plotly_config['font'],

            ),
            type=xaxis_type
        ),
        yaxis=go.layout.YAxis(
            title=go.layout.yaxis.Title(
                text=ylabel,
                font=plotly_config['font'],
            ),
        type=yaxis_type
        ),
        showlegend=True
    )


    return dcc.Graph(
        id=id,
        figure={'data': data,
                'layout': layout}, …
Run Code Online (Sandbox Code Playgroud)

plotly plotly-dash

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

将 CSV 上传到 Plotly Dash 并根据 Pandas 数据框渲染条形图

我是该框架的新手Plotly Dash,并尝试构建一个简单的仪表板:

  1. 允许用户上传 CSV 文件以进行图形分析。

  2. 根据步骤 #1 中上传的文件创建 Pandas 数据框。

    2a. 如果尚未选择 CSV 文件(以及生成的数据框),则不渲染任何内容。

  3. 根据上述数据框中包含的数据渲染基本条形图(或散点图、热图等)。

我的 CSV 文件中的数据类似于以下内容:

df = pd.DataFrame({'Make':['Ford', 'Ford', 'Ford', 'BMW', 'BMW', 'BMW', Mercedes', 'Mercedes', 'Mercedes'],
                          'Score':['88.6', '76.6', '100', '79.1', '86.8', '96.4', '97.3', '98.7', '98.5'],
                          'Dimension':['Speed', 'MPG', 'Styling', 'Speed', 'MPG', 'Styling', 'Speed', 'MPG', 'Styling'],
                          'Month':['Apr-19', 'Apr-19', 'Apr-19', 'Apr-19', 'Apr-19', 'Apr-19', 'Apr-19', 'Apr-19', 'Apr-19']})
Run Code Online (Sandbox Code Playgroud)

我的代码如下:

import base64
import datetime
import io
import dash
from dash.dependencies import Input, Output, State
import dash_core_components as dcc
import dash_html_components as …
Run Code Online (Sandbox Code Playgroud)

python pandas plotly plotly-dash

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

Plotly Express:如何在数据标签上添加数千个逗号分隔符

我正在使用该px.bar()函数来Plotly Express创建一些简单的条形图。

我的代码如下:

import plotly.express as px
import pandas as pd

test_df = pd.DataFrame({'Manufacturer':['Ford', 'Ford', 'Mercedes', 'BMW', 'Ford', 'Mercedes', 'BMW', 'Ford', 'Mercedes', 'BMW', 'Ford', 'Mercedes', 'BMW', 'Ford', 'Mercedes', 'BMW', 'Ford', 'Mercedes', 'BMW'],
                          'Metric':['Orders', 'Orders', 'Orders', 'Orders', 'Orders', 'Orders', 'Orders', 'Sales', 'Sales', 'Sales', 'Sales', 'Sales', 'Sales', 'Warranty', 'Warranty', 'Warranty', 'Warranty', 'Warranty', 'Warranty'],
                          'Sector':['Germany', 'Germany', 'Germany', 'Germany', 'USA', 'USA', 'USA', 'Germany', 'Germany', 'Germany', 'USA', 'USA', 'USA', 'Germany', 'Germany', 'Germany', 'USA', 'USA', 'USA'],
                          'Value':[45000, 70000, 90000, 65000, 40000, 65000, …
Run Code Online (Sandbox Code Playgroud)

plotly plotly-dash plotly-python

5
推荐指数
2
解决办法
6336
查看次数

如何修复:组件的 Children 属性是列表的列表,而不仅仅是 Python 中带有 Plotly-dash 的列表

我正在尝试使用绘图和破折号构建一个简单的网络仪表板。这是我想要获得的结构:

app = dash.Dash(__name__)

def Build_home_page():
    """
    build_welcome_banner [summary]

    [extended_summary]

    Returns
    -------
    [type]
        [description]
    """    ""
    
    return [
        html.Div(
            id="banner",
            className="box",
            children=[
                html.Div(
                    id="welcome-user",
                    children=[
                        html.H1("WELCOME TO THE DATA SCIENCE"),
                        html.H1("AND MACHINE LEARNING PLATFORM"),
                        html.Hr(className="tickline"),
                        html.Br(),
                        html.P(id="welcome-text1",
                               children= [
                                   "That provides you with the tools that allow you to explore your data seemlessly and"
                                   ]),
                        html.P(id= "welcome-text2",
                               children= [
                                   "get actionable insights from your data and allows you to easily apply Machine learning models to make predictions with your data" …
Run Code Online (Sandbox Code Playgroud)

python-3.x plotly plotly-dash plotly-python

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

Plotly Chart-Studio 配置问题以更改 Python 中的模式栏

我用 Python 创建了一个简单的 Plotly 图表,并且可以非常轻松地更改模式栏选项。但是,当我尝试将相同的图表发布到 Chart-Studio 时,并非所有模式栏配置都有效。有任何想法吗?

这是代码:

import pandas as pd
import numpy as np
import plotly.graph_objects as go

df = pd.DataFrame({'a':[2,4,6,8,10],'b':[3,6,9,12,15]})

fig = go.Figure()
    
fig.add_trace(go.Scatter(x=df.index, y=df['a'], mode='lines', name='a', line=dict(color='dodgerblue', dash='solid')))
fig.add_trace(go.Scatter(x=df.index, y=df['b'], mode='lines', name='b', line=dict(color='lightsalmon', dash='dash')))

fig.update_layout(
    title='a and b',
    autosize=False,
    width=500,
    height=500,
    newshape=dict(line_color='mediumaquamarine', line_width=2, opacity=1)
)

config = {
    'modeBarButtonsToAdd' : ['drawline', 'drawopenpath', 'drawrect', 'eraseshape'],
    'displaylogo'         : False
}

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

出现的图形已删除徽标,并且模式栏上的附加按钮按其应有的方式显示...

但是,如果我尝试将其发布到 Chart-Studio:

import chart_studio.plotly as py
import chart_studio

chart_studio.tools.set_credentials_file(username='xxxxx', api_key='#####')

py.plot(fig, filename='a and b', auto_open=False, config=config) …
Run Code Online (Sandbox Code Playgroud)

python plotly plotly-dash plotly-python

5
推荐指数
0
解决办法
465
查看次数

Dash datepicker max_date_allowed 当前日期无法正常工作

我的仪表板使用 dash,并部署在 AWS Elastic Beanstalk 上。
Datepicker 中存在问题。我正在使用 max_date_allowed=dt.date(dt.now())

因此,在部署应用程序的那天,一切都运行良好。但从第二天开始, max_date_allowed 会固定为应用程序部署的日期,并且我们无法选择超出应用程序部署日期的日期。
仅当我们在环境中从操作菜单中选择重新启动应用程序服务器时,它才会再次起作用。

这里可能有什么问题?

下面是我们使用的日期选择器片段。

dcc.Tabs([
        dcc.Tab(label='DDR by Date (Default DDR - Last Day)', value='tab-1', children=[
            dcc.DatePickerSingle(
                id='my-date-picker-single',
                min_date_allowed=dt(2020, 1, 18),
                max_date_allowed=dt.date(dt.now()),
                initial_visible_month=dt.date(dt.now()),
                placeholder='Select a date',
                display_format='DD/MM/YYYY'
            ),
            html.Button(id='submit-button', n_clicks=0, children='Submit'),
            html.Div(id='output-container-date-picker-single')
        ]),
Run Code Online (Sandbox Code Playgroud)

python datepicker amazon-web-services amazon-elastic-beanstalk plotly-dash

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

更改破折号下拉列表中文本输入的字体颜色

当我在破折号应用程序中输入 dcc.dropdown 时,我试图更改文本的颜色。下拉列表元素的颜色很好,但文本输入看起来像是默认的。

有什么帮助吗?

谢谢。

下拉输入文本

plotly-dash

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

回调失败:服务器没有响应 - 尝试更新 Dash 中的图表时

我们正在从不同版本的表中读取性能数据,并创建折线图来比较不同版本的性能指标。当应用程序在本地运行时,回调将按其应有的方式触发(在页面加载时),并且应用程序可用。但是,当应用程序部署到 UNIX 服务器时,回调将停止工作。

错误:回调失败:服务器未响应。

在 http://server_ip:port/_dash-component-suites/dash_renderer/dash_renderer.v1_5_1m1593111735.dev.js:33217:11

callback plotly-dash

5
推荐指数
0
解决办法
2104
查看次数

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
查看次数