.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/dataset/visualization/plot_plotly_dataset_plot.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_dataset_visualization_plot_plotly_dataset_plot.py: Interactive visualization using plotly ====================================== By default, |g| uses `matplotlib `__ for data visualization. However, for web-based interactive visualizations, `plotly `__ can be appreciated. For this reason, |g| proposes plotly versions of some visualizations which can be generated using the option ``file_format="html"`` of the method :meth:`.DatasetPlot.execute`. In that case, this method returns a list of plotly figures. When ``save=True`` (default), the figures are saved on the disk. When ``show=True``, the figures are displayed in the web browser. .. GENERATED FROM PYTHON SOURCE LINES 34-42 .. code-block:: Python from __future__ import annotations from numpy import array from gemseo.datasets.dataset import Dataset from gemseo.post.dataset.bars import BarPlot .. GENERATED FROM PYTHON SOURCE LINES 43-45 In this example, we create a simple dataset: .. GENERATED FROM PYTHON SOURCE LINES 45-51 .. code-block:: Python dataset = Dataset() dataset.add_variable("x1", array([[0.25, 0.35], [0.75, 0.85]])) dataset.add_variable("x2", array([[0.5], [0.5]])) dataset.add_variable("x3", array([[0.75], [0.25]])) dataset.index = ["series_1", "series_2"] .. GENERATED FROM PYTHON SOURCE LINES 52-54 then, we create a :class:`.BarPlot`: .. GENERATED FROM PYTHON SOURCE LINES 54-57 .. code-block:: Python plot = BarPlot(dataset, n_digits=2) plot.colormap = "PiYG" .. GENERATED FROM PYTHON SOURCE LINES 58-59 generate the plotly figure: .. GENERATED FROM PYTHON SOURCE LINES 59-61 .. code-block:: Python plotly_figure = plot.execute(save=False, file_format="html")[0] .. GENERATED FROM PYTHON SOURCE LINES 62-63 and visualize it: .. GENERATED FROM PYTHON SOURCE LINES 63-65 .. code-block:: Python plotly_figure .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 66-74 .. warning:: The plotly figures can be truncated both at the bottom and on the right in the web documentation. This an issue related to the documentation plugin. The problem is solved by resizing the window. Alternatively, setting ``show=True`` will display the figure in a new tab of your web browser. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.099 seconds) .. _sphx_glr_download_examples_dataset_visualization_plot_plotly_dataset_plot.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_plotly_dataset_plot.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_plotly_dataset_plot.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_plotly_dataset_plot.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_