MCPcopy Index your code
hub / github.com/plotly/plotly.py / write_html

Function write_html

plotly/io/_html.py:352–517  ·  view source on GitHub ↗

Write a figure to an HTML file representation Parameters ---------- fig: Figure object or dict representing a figure file: str or writeable A string representing a local file path or a writeable object (e.g. a pathlib.Path object or an open file descript

(
    fig,
    file,
    config=None,
    auto_play=True,
    include_plotlyjs=True,
    include_mathjax=False,
    post_script=None,
    full_html=True,
    animation_opts=None,
    validate=True,
    default_width="100%",
    default_height="100%",
    auto_open=False,
    div_id=None,
)

Source from the content-addressed store, hash-verified

350
351
352def write_html(
353 fig,
354 file,
355 config=None,
356 auto_play=True,
357 include_plotlyjs=True,
358 include_mathjax=False,
359 post_script=None,
360 full_html=True,
361 animation_opts=None,
362 validate=True,
363 default_width="100%",
364 default_height="100%",
365 auto_open=False,
366 div_id=None,
367):
368 """
369 Write a figure to an HTML file representation
370
371 Parameters
372 ----------
373 fig:
374 Figure object or dict representing a figure
375 file: str or writeable
376 A string representing a local file path or a writeable object
377 (e.g. a pathlib.Path object or an open file descriptor)
378 config: dict or None (default None)
379 Plotly.js figure config options
380 auto_play: bool (default=True)
381 Whether to automatically start the animation sequence on page load
382 if the figure contains frames. Has no effect if the figure does not
383 contain frames.
384 include_plotlyjs: bool or string (default True)
385 Specifies how the plotly.js library is included/loaded in the output
386 div string.
387
388 If True, a script tag containing the plotly.js source code (~3MB)
389 is included in the output. HTML files generated with this option are
390 fully self-contained and can be used offline.
391
392 If 'cdn', a script tag that references the plotly.js CDN is included
393 in the output. The url used is versioned to match the bundled plotly.js.
394 HTML files generated with this option are about 3MB smaller than those
395 generated with include_plotlyjs=True, but they require an active
396 internet connection in order to load the plotly.js library.
397
398 If 'directory', a script tag is included that references an external
399 plotly.min.js bundle that is assumed to reside in the same
400 directory as the HTML file. If `file` is a string to a local file
401 path and `full_html` is True, then the plotly.min.js bundle is copied
402 into the directory of the resulting HTML file. If a file named
403 plotly.min.js already exists in the output directory then this file
404 is left unmodified and no copy is performed. HTML files generated
405 with this option can be used offline, but they require a copy of
406 the plotly.min.js bundle in the same directory. This option is
407 useful when many figures will be saved as HTML files in the same
408 directory because the plotly.js source code will be included only
409 once per output directory, rather than once per output file.

Callers 2

to_mimebundleMethod · 0.90
renderMethod · 0.90

Calls 4

get_plotlyjsFunction · 0.90
to_htmlFunction · 0.85
writeMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected