【发布时间】:2019-08-14 15:12:40
【问题描述】:
我正在尝试使用 plotly 和 dash 为 webapp 创建一个简单的折线图。我想要一条连接两点的线。我希望一个点是红色的,另一个是绿色的。到目前为止,这是我所拥有的:
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets = external_stylesheets)
graph = dcc.Graph(figure = {
'data' : [
go.Scatter(x = [1,4], y = [2,3], mode = 'lines+markers', opacity = 0.7, marker = {
'size' : 15,
'line' : {'width' : 0.5, 'color' : 'black'}
})
]
})
app.layout = html.Div([graph])
if __name__ == '__main__':
app.run_server(debug = False)
我在 Jupyter 笔记本中运行此代码,其中包含所有最新的软件包。 如果我运行这段代码,我会得到我想要的线图,但两个点都是蓝色的。我希望 (1, 2) 对应的点为红色, (4, 3) 为绿色。我该怎么做呢? 提前非常感谢您!
【问题讨论】:
标签: python plotly plotly-dash