.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "extensions/sphinx-gallery/plot_02_multiple_figures.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_extensions_sphinx-gallery_plot_02_multiple_figures.py: Multiple Figures ================ This example demonstrates generating multiple figures in a single example. Each figure is displayed in sequence with accompanying explanatory text. .. GENERATED FROM PYTHON SOURCE LINES 8-12 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 13-17 First Figure: Scatter Plot -------------------------- Random scatter data with color mapping based on distance from origin. .. GENERATED FROM PYTHON SOURCE LINES 17-33 .. code-block:: Python np.random.seed(42) x = np.random.randn(50) y = np.random.randn(50) colors = np.sqrt(x**2 + y**2) plt.figure(figsize=(6, 6)) plt.scatter(x, y, c=colors, cmap="viridis", s=100, alpha=0.7) plt.colorbar(label="Distance from origin") plt.xlabel("X") plt.ylabel("Y") plt.title("Scatter Plot with Color Mapping") plt.grid(True, alpha=0.3) plt.tight_layout() plt.show() .. image-sg:: /extensions/sphinx-gallery/images/sphx_glr_plot_02_multiple_figures_001.png :alt: Scatter Plot with Color Mapping :srcset: /extensions/sphinx-gallery/images/sphx_glr_plot_02_multiple_figures_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 34-38 Second Figure: Bar Chart ------------------------ Categorical data visualization using a horizontal bar chart. .. GENERATED FROM PYTHON SOURCE LINES 38-49 .. code-block:: Python categories = ["Category A", "Category B", "Category C", "Category D", "Category E"] values = [23, 45, 12, 67, 34] plt.figure(figsize=(8, 5)) bars = plt.barh(categories, values, color=plt.cm.tab10.colors[:5]) plt.xlabel("Value") plt.title("Horizontal Bar Chart") plt.tight_layout() plt.show() .. image-sg:: /extensions/sphinx-gallery/images/sphx_glr_plot_02_multiple_figures_002.png :alt: Horizontal Bar Chart :srcset: /extensions/sphinx-gallery/images/sphx_glr_plot_02_multiple_figures_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 50-54 Third Figure: Pie Chart ----------------------- Proportional data shown as a pie chart with percentage labels. .. GENERATED FROM PYTHON SOURCE LINES 54-63 .. code-block:: Python sizes = [35, 25, 20, 15, 5] labels = ["Component A", "Component B", "Component C", "Component D", "Other"] plt.figure(figsize=(6, 6)) plt.pie(sizes, labels=labels, autopct="%1.1f%%", startangle=90) plt.title("Distribution by Component") plt.tight_layout() plt.show() .. image-sg:: /extensions/sphinx-gallery/images/sphx_glr_plot_02_multiple_figures_003.png :alt: Distribution by Component :srcset: /extensions/sphinx-gallery/images/sphx_glr_plot_02_multiple_figures_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.195 seconds) .. _sphx_glr_download_extensions_sphinx-gallery_plot_02_multiple_figures.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_multiple_figures.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_multiple_figures.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_multiple_figures.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_