python - Plotly-Dash:如何从 Dash WebApp 中删除状态图标?
问题描述
我正在使用 Dash plotly 为 IPL 构建 Web Dashboard。那里有一个显示网络服务器状态的状态图标。
我怎样才能从网页中删除它?我无法解释太多所以添加下面标记为黄色的图像
解决方案
只需Debug=False
在这里设置就可以了:
app.run_server(debug=False)
我将使用我以前的一篇文章来说明它。您将在下面找到完整的代码片段。
1 - app.run_server(debug=True)
2 - app.run_server(debug=False)
完整代码
import numpy as np
import plotly.express as px
import plotly.graph_objects as go
from jupyter_dash import JupyterDash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
from sklearn.pipeline import make_pipeline
from IPython.core.debugger import set_trace
# Load Data
df = px.data.tips()
# Build App
app = JupyterDash(__name__)
app.layout = html.Div([
html.H1("ScikitLearn: Polynomial features"),
dcc.Graph(id='graph'),
html.Label([
"Set number of features",
dcc.Slider(id='PolyFeat',
min=1,
max=6,
marks={i: '{}'.format(i) for i in range(10)},
value=1,
)
]),
])
# Define callback to update graph
@app.callback(
Output('graph', 'figure'),
[Input("PolyFeat", "value")]
)
def update_figure(nFeatures):
global model
# data
df = px.data.tips()
x=df['total_bill']
y=df['tip']
# model
model = make_pipeline(PolynomialFeatures(nFeatures), LinearRegression())
model.fit(np.array(x).reshape(-1, 1), y)
x_reg = x.values
y_reg = model.predict(x_reg.reshape(-1, 1))
df['model']=y_reg
# figure setup and trace for observations
fig = go.Figure()
fig.add_traces(go.Scatter(x=df['total_bill'], y=df['tip'], mode='markers', name = 'observations'))
# trace for polynomial model
df=df.sort_values(by=['model'])
fig.add_traces(go.Scatter(x=df['total_bill'], y=df['model'], mode='lines', name = 'model'))
# figure layout adjustments
fig.update_layout(yaxis=dict(range=[0,12]))
fig.update_layout(xaxis=dict(range=[0,60]))
#print(df['model'].tail())
fig.update_layout(template = 'plotly_dark')
return(fig)
# Run app and display result inline in the notebook
app.enable_dev_tools(dev_tools_hot_reload =True)
app.run_server(mode='inline', port = 8040, dev_tools_ui=True, debug=False,
dev_tools_hot_reload =True, threaded=True)
推荐阅读
- ios - 导入模式下的 UIDocumentPickerViewController 返回 .icloud 文件
- powershell - 以值作为参数的 Powershell 错误
- gmail - 我点击了垃圾邮件中的删除按钮
- vue.js - 如何访问 Vue API 中引用的过滤器?
- python - 如何使用带有 python 和烧瓶的谷歌地方获取附近的地方
- java - Hibernate+SQLServer / 批量只插入新记录
- java - 通过电子邮件发送的范围报告不加载屏幕截图
- go - 卷曲 http-server 可以,但浏览器无法正常工作
- git - 这个 git 输出是什么意思?
- jquery - 如何从 Kendo UI Grid 中创建的过滤器中选择所有行?