IVR*_*IVR 6 css python plotly plotly-dash
我有一个简单的 Dash 应用程序,我想通过 CSS 设置绘图的字体和颜色。这是我的app.py样子:
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objects as go
def generate_plot():
fig = go.Figure()
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[1, 2, 3]))
return fig
app = dash.Dash(__name__)
app.layout = html.Div(children=[
html.H1(children="title", className="title"),
dcc.Graph(figure=generate_plot(), class="plot")
])
Run Code Online (Sandbox Code Playgroud)
我还有一个文件assets/style.css ,我想用描述dcc.Graph对象外观的内容扩展这个文件。这可能吗?如果是,那我该怎么做?我希望能够设置字体、背景颜色、线条/标记颜色等。不幸的是,类似.plot { background-color: aqua; }CSS 的东西没有效果。此外,html, body {font-family: serif; }也没有任何影响。
我通过以下方式在仅开发的基础上解决了其中一些问题:
:8050)。app.css.append_css(dict(external_url='http://localhost/style.css'))
html { background-color: aqua;}
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[1, 2, 3], textfont={'family': 'serif'}))
| 归档时间: |
|
| 查看次数: |
2798 次 |
| 最近记录: |