.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/dataset/visualization/plot_bars.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_bars.py: Bars ==== .. GENERATED FROM PYTHON SOURCE LINES 26-38 .. code-block:: Python from __future__ import annotations from numpy import array from gemseo import configure_logger from gemseo.datasets.dataset import Dataset from gemseo.post.dataset.bars import BarPlot configure_logger() .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 39-43 Build a dataset --------------- Let us consider two series of values for the variables *x1*, *x2* and *x3* which we arrange in rows in a :class:`.Dataset`: .. GENERATED FROM PYTHON SOURCE LINES 43-50 .. 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"] dataset .. raw:: html
GROUP parameters
VARIABLE x1 x2 x3
COMPONENT 0 1 0 0
series_1 0.25 0.35 0.5 0.75
series_2 0.75 0.85 0.5 0.25


.. GENERATED FROM PYTHON SOURCE LINES 51-55 Plot the two series on a bar chart ---------------------------------- We can use the :class:`.BarPlot` to display these series, with one color per series and the values grouped by variable name: .. GENERATED FROM PYTHON SOURCE LINES 55-58 .. code-block:: Python plot = BarPlot(dataset, n_digits=2) plot.colormap = "PiYG" plot.execute(save=False, show=True) .. image-sg:: /examples/dataset/visualization/images/sphx_glr_plot_bars_001.png :alt: plot bars :srcset: /examples/dataset/visualization/images/sphx_glr_plot_bars_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [
] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.154 seconds) .. _sphx_glr_download_examples_dataset_visualization_plot_bars.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_bars.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_bars.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_