Skip to content

plotly.io.write_html return #3599

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
radcoreai opened this issue Feb 18, 2022 · 2 comments
Closed

plotly.io.write_html return #3599

radcoreai opened this issue Feb 18, 2022 · 2 comments
Assignees
Labels
bug something broken P3 backlog

Comments

@radcoreai
Copy link

radcoreai commented Feb 18, 2022

Hello!

I am trying to convert a plotly plot to an HTML embeddable div (reproducible example below):

import plotly.express as px
import plotly

fig = px.scatter([1,2], [3,4])
html = plotly.io.write_html(fig, "fig.html")


type(html)
NoneType

While the string representation of the HTML is indeed written to the file, the documentation clearly says that the method returns the string representation.

Returns
Representation of figure as an HTML div string

As for my use case it would be great to have the string directly returned so I can use it externally (to avoid an useless write-read operation each time I want to generate a HTML plot). Either that or let's update the docs to remove the confusion?

I could solve it either way; Let me know what you think would be the best solution.

Thank you!

@nicolaskruchten
Copy link
Contributor

Yeah, looks like the docstring there is incorrect. write_html() writes to a file and to_html() returns the string :)

@LiamConnors
Copy link
Member

This was fixed in #4656

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

No branches or pull requests

4 participants