Convert a matplotlib figure to a Plotly graph stored locally as HTML. For more information on converting matplotlib visualizations to plotly graphs, call help(plotly.tools.mpl_to_plotly) For more information on creating plotly charts locally as an HTML document or string, call
(
mpl_fig,
resize=False,
strip_style=False,
verbose=False,
show_link=False,
link_text="Export to plot.ly",
validate=True,
output_type="file",
include_plotlyjs=True,
filename="temp-plot.html",
auto_open=True,
image=None,
image_filename="plot_image",
image_height=600,
image_width=800,
)
| 610 | |
| 611 | |
| 612 | def plot_mpl( |
| 613 | mpl_fig, |
| 614 | resize=False, |
| 615 | strip_style=False, |
| 616 | verbose=False, |
| 617 | show_link=False, |
| 618 | link_text="Export to plot.ly", |
| 619 | validate=True, |
| 620 | output_type="file", |
| 621 | include_plotlyjs=True, |
| 622 | filename="temp-plot.html", |
| 623 | auto_open=True, |
| 624 | image=None, |
| 625 | image_filename="plot_image", |
| 626 | image_height=600, |
| 627 | image_width=800, |
| 628 | ): |
| 629 | """ |
| 630 | Convert a matplotlib figure to a Plotly graph stored locally as HTML. |
| 631 | |
| 632 | For more information on converting matplotlib visualizations to plotly |
| 633 | graphs, call help(plotly.tools.mpl_to_plotly) |
| 634 | |
| 635 | For more information on creating plotly charts locally as an HTML document |
| 636 | or string, call help(plotly.offline.plot) |
| 637 | |
| 638 | mpl_fig -- a matplotlib figure object to convert to a plotly graph |
| 639 | |
| 640 | Keyword arguments: |
| 641 | resize (default=False) -- allow plotly to choose the figure size. |
| 642 | strip_style (default=False) -- allow plotly to choose style options. |
| 643 | verbose (default=False) -- print message. |
| 644 | show_link (default=False) -- display a link in the bottom-right corner of |
| 645 | of the chart that will export the chart to Plotly Cloud or |
| 646 | Plotly Enterprise |
| 647 | link_text (default='Export to plot.ly') -- the text of export link |
| 648 | validate (default=True) -- validate that all of the keys in the figure |
| 649 | are valid? omit if your version of plotly.js has become outdated |
| 650 | with your version of graph_reference.json or if you need to include |
| 651 | extra, unnecessary keys in your figure. |
| 652 | output_type ('file' | 'div' - default 'file') -- if 'file', then |
| 653 | the graph is saved as a standalone HTML file and `plot` |
| 654 | returns None. |
| 655 | If 'div', then `plot` returns a string that just contains the |
| 656 | HTML <div> that contains the graph and the script to generate the |
| 657 | graph. |
| 658 | Use 'file' if you want to save and view a single graph at a time |
| 659 | in a standalone HTML file. |
| 660 | Use 'div' if you are embedding these graphs in an HTML file with |
| 661 | other graphs or HTML markup, like an HTML report or a website. |
| 662 | include_plotlyjs (default=True) -- If True, include the plotly.js |
| 663 | source code in the output file or string. |
| 664 | Set as False if your HTML file already contains a copy of the plotly.js |
| 665 | library. |
| 666 | filename (default='temp-plot.html') -- The local filename to save the |
| 667 | outputted chart to. If the filename already exists, it will be |
| 668 | overwritten. This argument only applies if `output_type` is 'file'. |
| 669 | auto_open (default=True) -- If True, open the saved file in a |