Skip to content

What about Dash? #1654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nicolaskruchten opened this issue Jan 10, 2020 · 6 comments
Closed

What about Dash? #1654

nicolaskruchten opened this issue Jan 10, 2020 · 6 comments
Assignees

Comments

@nicolaskruchten
Copy link
Contributor

nicolaskruchten commented Jan 10, 2020

We need to add, to every R and Python page other than the "Is Plotly Free?" pages, a section at the bottom that reads something like:

What about Dash?

Dash is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library. Everywhere in this page that you see fig.show(), you can display the same figure in a Dash application by passing it to the figure argument of the Graph component from the built-in dash_core_components package like this:

import plotly.graph_objects as go # or plotly.express as px
fig = go.Figure() # or the output of any Plotly Express function
# fig.add_trace( ... )
# fig.update_layout( ... ) 

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div(
    dcc.Graph(figure=fig)
)

app.run_server(debug=True)
@nicolaskruchten
Copy link
Contributor Author

@jdamiba let's try to knock this one out this week please.

@nicolaskruchten
Copy link
Contributor Author

Open to ideas about the phrasing and the exact code being shown. maybe the code needs to be page-specific, so as to reuse one of the simpler cells, to make it an actual copy-pasteable example... that would be labour-intensive but worth it IMO.

@nicolaskruchten
Copy link
Contributor Author

@chriddyp @emmanuelle @alexcjohnson input is welcome on this first pass!

The idea here is that all doc pages get the same little block (for now) and then in some near future we can do per-page blocks that don't show an empty figure.

@jdamiba and I figured out that actually we can append a little bit of Markdown to the notebooks right before rendering them in the CI step, so that this block will get formatted just like any other doc, without having to be manually pasted everywhere. Here is the R PR for this plotly/plotly.r-docs#41 and the Python bit can just go in here somewhere once we agree on the details: https://github.com/plotly/plotly.py/blob/master/doc/Makefile#L32

@chriddyp
Copy link
Member

Nice! I might change the first line to be:

fig = go.Figure() # or the output of any Plotly Express function, like `fig = px.scatter(...)`

@chriddyp
Copy link
Member

and also:

app.layout = html.Div([
    dcc.Graph(figure=fig)
])

@chriddyp
Copy link
Member

Since most folks working in plotly are working in jupyter, maybe let's also do this until we fix this in the library level

app.run_server(debug=True, use_reloader=False)  # Turn off reloader if inside Jupyter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants