我有一个简单的 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")
])
我也有一个文件
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'}))
关于python - 破折号 : how to control graph style via CSS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60915571/