I have a simple Dash application and I would like to set fonts and colours of my plots via CSS. Here is what my app.py
looks like:
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")
])
I also have a file assets/style.css
and i deally, I would like to extend this file with content that describes how my dcc.Graph
objects should look. Is this possible? If it is, then how would I do it? I would like to be able to set fonts, background colours, line/marker colours, etc. Unfortunately, something like .plot { background-color: aqua; }
in CSS has no effect. Also, html, body {font-family: serif; }
has no effect too.
I have addressed some of these problems, on a development-only basis, via the following:
:8050
default).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'}))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With