-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Resizable, minimal, embeddable output from plotly.offline.plot #1043
Comments
With some help from this stack overflow post found a workaround for this. Basically let it generate the html, however suppress the automatic opening with import plotly
import bs4
# return as html fragment
# the include_plotlyjs argument seems to be
# ignored as it's included regardless when outputting to div
# found an open issue on here - https://github.com/plotly/plotly.py/issues/1043
plotly.offline.plot(
plot_output,
filename = filename,
config = plot_config,
include_plotlyjs = False,
auto_open = False,
)
# load the file
with open(filename) as inf:
txt = inf.read()
soup = bs4.BeautifulSoup(txt)
# add in the latest plot-ly js as per https://stackoverflow.com/a/38033016/2805700
js_src = soup.new_tag("script", src="https://cdn.plot.ly/plotly-latest.min.js")
# insert it into the document
soup.head.insert(0, js_src)
# save the file again
with open(filename, "w") as outf:
outf.write(str(soup)) |
Hi @mchels , Yeah, I don't see any reason why resizing shouldn't be supported when Thanks for bringing it up, and for the helpful background research. |
I've got this issue currently as well on a project I'm working on. Would love to have resizing work when I'm building a dashboard that graphs the data for various environmental sensors on a single page. When I've tried setting Any available fix or workaround? |
Hi all, |
Bumping this to v3.4.0 because that's where the latex/MathJax work is going to happen. |
Done in #1234 |
In plotly.offline.plot is it intentional that resizing is only available for
output_type == 'div'
if plotly.js is included in the output: https://github.com/plotly/plotly.py/blob/master/plotly/offline/offline.py#L526-L537This means that currently you cannot generate a minimal (no plotly.js), embeddable (
output_type == 'div'
) script that is also resizable which seems not to be the intention in the PR that made the change: #717Example:
gives for
fig_div
:Setting
include_plotlyjs=True
gives at the endApologies if I'm missing something obvious.
The text was updated successfully, but these errors were encountered: