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

Function to_html

plotly/io/_html.py:35–349  ·  view source on GitHub ↗

Convert a figure to an HTML string representation. Parameters ---------- fig: Figure object or dict representing a figure config: dict or None (default None) Plotly.js figure config options auto_play: bool (default=True) Whether to automatically star

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

Source from the content-addressed store, hash-verified

33
34
35def to_html(
36 fig,
37 config=None,
38 auto_play=True,
39 include_plotlyjs=True,
40 include_mathjax=False,
41 post_script=None,
42 full_html=True,
43 animation_opts=None,
44 default_width="100%",
45 default_height="100%",
46 validate=True,
47 div_id=None,
48):
49 """
50 Convert a figure to an HTML string representation.
51
52 Parameters
53 ----------
54 fig:
55 Figure object or dict representing a figure
56 config: dict or None (default None)
57 Plotly.js figure config options
58 auto_play: bool (default=True)
59 Whether to automatically start the animation sequence on page load
60 if the figure contains frames. Has no effect if the figure does not
61 contain frames.
62 include_plotlyjs: bool or string (default True)
63 Specifies how the plotly.js library is included/loaded in the output
64 div string.
65
66 If True, a script tag containing the plotly.js source code (~3MB)
67 is included in the output. HTML files generated with this option are
68 fully self-contained and can be used offline.
69
70 If 'cdn', a script tag that references the plotly.js CDN is included
71 in the output. The url used is versioned to match the bundled plotly.js.
72 HTML files generated with this option are about 3MB smaller than those
73 generated with include_plotlyjs=True, but they require an active
74 internet connection in order to load the plotly.js library.
75
76 If 'directory', a script tag is included that references an external
77 plotly.min.js bundle that is assumed to reside in the same
78 directory as the HTML file.
79
80 If a string that ends in '.js', a script tag is included that
81 references the specified path. This approach can be used to point
82 the resulting HTML file to an alternative CDN or local bundle.
83
84 If False, no script tag referencing plotly.js is included. This is
85 useful when the resulting div string will be placed inside an HTML
86 document that already loads plotly.js. This option is not advised
87 when full_html=True as it will result in a non-functional html file.
88 include_mathjax: bool or string (default False)
89 Specifies how the MathJax.js library is included in the output html
90 div string. MathJax is required in order to display labels
91 with LaTeX typesetting.
92

Callers 5

to_mimebundleMethod · 0.90
renderMethod · 0.90
renderMethod · 0.90
to_mimebundleMethod · 0.90
write_htmlFunction · 0.85

Calls 10

to_json_plotlyFunction · 0.90
_get_jconfigFunction · 0.90
get_plotlyjsFunction · 0.90
plotly_cdn_urlFunction · 0.90
_generate_sri_hashFunction · 0.85
getMethod · 0.45
formatMethod · 0.45
popMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected