.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/plotly/plot_main12_mpl2ply.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_plotly_plot_main12_mpl2ply.py: 12. Matplotlib to Plotly ============================== [REF] https://github.com/plotly/plotly.py/issues/3624#issuecomment-1161805210 .. note:: In the latest commit of plotly packages/python/plotly/plotly/matplotlylib/mpltools.py line 368, it still calls is_frame_like() function. There is already an issue tracking this. You may need choose to downgrade Matplotlib if you still want to use mpl_to_plotly() function. .. GENERATED FROM PYTHON SOURCE LINES 12-58 .. image-sg:: /_examples/plotly/images/sphx_glr_plot_main12_mpl2ply_001.png :alt: plot main12 mpl2ply :srcset: /_examples/plotly/images/sphx_glr_plot_main12_mpl2ply_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none '\n# Convert to plotly\nimport plotly.tools as tls\n\n# Convert to plotly\nfig = tls.mpl_to_plotly(fig)\n\nprint(fig.data)\n\n# Show\n#fig.show()\nfig\n' | .. code-block:: default :lineno-start: 13 # Libraries import numpy as np import matplotlib.pyplot as plt try: __file__ TERMINAL = True except: TERMINAL = False # Create data x = np.arange(10) y = 2.5 * np.sin(x / 20 * np.pi) yerr = np.linspace(0.05, 0.2, 10) # Figure fig = plt.figure() plt.errorbar(x, y + 3, yerr=yerr, label='both limits (default)') plt.errorbar(x, y + 2, yerr=yerr, uplims=True, label='uplims=True') plt.errorbar(x, y + 1, yerr=yerr, uplims=True, lolims=True, label='uplims=True, lolims=True') # Add error upperlimits = [True, False] * 5 lowerlimits = [False, True] * 5 plt.errorbar(x, y, yerr=yerr, uplims=upperlimits, lolims=lowerlimits, label='subsets of uplims and lolims') # add legent plt.legend(loc='lower right') """ # Convert to plotly import plotly.tools as tls # Convert to plotly fig = tls.mpl_to_plotly(fig) print(fig.data) # Show #fig.show() fig """ .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.112 seconds) .. _sphx_glr_download__examples_plotly_plot_main12_mpl2ply.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_main12_mpl2ply.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_main12_mpl2ply.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_