Convert a matplotlib figure to a plotly graph and plot inside an IPython notebook without connecting to an external server. To save the chart to Plotly Cloud or Plotly Enterprise, use `plotly.plotly.plot_mpl`. For more information on converting matplotlib visualizations to plo
(
mpl_fig,
resize=False,
strip_style=False,
verbose=False,
show_link=False,
link_text="Export to plot.ly",
validate=True,
image=None,
image_filename="plot_image",
image_height=600,
image_width=800,
)
| 713 | |
| 714 | |
| 715 | def iplot_mpl( |
| 716 | mpl_fig, |
| 717 | resize=False, |
| 718 | strip_style=False, |
| 719 | verbose=False, |
| 720 | show_link=False, |
| 721 | link_text="Export to plot.ly", |
| 722 | validate=True, |
| 723 | image=None, |
| 724 | image_filename="plot_image", |
| 725 | image_height=600, |
| 726 | image_width=800, |
| 727 | ): |
| 728 | """ |
| 729 | Convert a matplotlib figure to a plotly graph and plot inside an IPython |
| 730 | notebook without connecting to an external server. |
| 731 | |
| 732 | To save the chart to Plotly Cloud or Plotly Enterprise, use |
| 733 | `plotly.plotly.plot_mpl`. |
| 734 | |
| 735 | For more information on converting matplotlib visualizations to plotly |
| 736 | graphs call `help(plotly.tools.mpl_to_plotly)` |
| 737 | |
| 738 | For more information on plotting plotly charts offline in an Ipython |
| 739 | notebook call `help(plotly.offline.iplot)` |
| 740 | |
| 741 | mpl_fig -- a matplotlib.figure to convert to a plotly graph |
| 742 | |
| 743 | Keyword arguments: |
| 744 | resize (default=False) -- allow plotly to choose the figure size. |
| 745 | strip_style (default=False) -- allow plotly to choose style options. |
| 746 | verbose (default=False) -- print message. |
| 747 | show_link (default=False) -- display a link in the bottom-right corner of |
| 748 | of the chart that will export the chart to |
| 749 | Plotly Cloud or Plotly Enterprise |
| 750 | link_text (default='Export to plot.ly') -- the text of export link |
| 751 | validate (default=True) -- validate that all of the keys in the figure |
| 752 | are valid? omit if your version of plotly.js |
| 753 | has become outdated with your version of |
| 754 | graph_reference.json or if you need to include |
| 755 | extra, unnecessary keys in your figure. |
| 756 | image (default=None |'png' |'jpeg' |'svg' |'webp') -- This parameter sets |
| 757 | the format of the image to be downloaded, if we choose to download an |
| 758 | image. This parameter has a default value of None indicating that no |
| 759 | image should be downloaded. |
| 760 | image_filename (default='plot_image') -- Sets the name of the file your |
| 761 | image will be saved to. The extension should not be included. |
| 762 | image_height (default=600) -- Specifies the height of the image in `px`. |
| 763 | image_width (default=800) -- Specifies the width of the image in `px`. |
| 764 | |
| 765 | Example: |
| 766 | ``` |
| 767 | from plotly.offline import init_notebook_mode, iplot_mpl |
| 768 | import matplotlib.pyplot as plt |
| 769 | |
| 770 | fig = plt.figure() |
| 771 | x = [10, 15, 20, 25, 30] |
| 772 | y = [100, 250, 200, 150, 300] |
no test coverage detected