Interactive visualization using plotly#

By default, GEMSEO uses matplotlib for data visualization. However, for web-based interactive visualizations, plotly can be appreciated. For this reason, GEMSEO proposes plotly versions of some visualizations which can be generated using the option file_format="html" of the method 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.

from __future__ import annotations

from numpy import array

from gemseo.datasets.dataset import Dataset
from gemseo.post.dataset.bars import BarPlot

In this example, we create a simple dataset:

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"]

then, we create a BarPlot:

plot = BarPlot(dataset, n_digits=2)
plot.colormap = "PiYG"

generate the plotly figure:

plotly_figure = plot.execute(save=False, file_format="html")[0]

and visualize it:

plotly_figure


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.

Total running time of the script: (0 minutes 0.099 seconds)

Gallery generated by Sphinx-Gallery