0

What is the relationship between Dash Core Components Graph() and Plotly Express?

For example, I can create a graph with

dcc.Graph(
            figure={
                "data": [
                    {
                        "x": data["DateTime"],
                        "y": data["Gold"],
                        "type": "lines",
                    },
                ],
                "layout": {
                    "title": "Gold Price"
                },
            },
        )

but many of the tutorials I've seen use plotly express in conjunction with dcc.Graph(), so it doesn't appear to be an either/or situation.

Is it a bad idea to just use dcc.Graph()? What would the advantage be of using plotly express as well?

1 Answer 1

1

The benefit of using plotly express is that it’s easier to make a figure. I use dash a lot and I’ve never made a dcc.Graph() building it like you described. I’ve always used express or graph_objects. Either way, when you make a the dcc graph object is the same after it’s made.

Sign up to request clarification or add additional context in comments.

3 Comments

Please add further details to expand on your answer, such as working code or documentation citations.
Could you possibly show me how I would achieve the same result as in my example with plotly express?
Sure. dcc.Graph(figure=px.line(x=data['DateTime'], y=data['Gold'], title='Gold Price'))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.