.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_gallery/images_contours_and_fields/plot_multi_image.f90" .. 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_auto_gallery_images_contours_and_fields_plot_multi_image.f90: Multiple Images Display ======================= This example shows how to display multiple images side by side in a single figure using subplots. This is useful for comparing different datasets, showing processing stages, or presenting multiple related visualizations. .. GENERATED FROM PYTHON SOURCE LINES 7-15 .. code-block:: Fortran program plot_multi_image use fplotlib, only: colorbar, dp, figure, imshow, savefig, subplot, title implicit none integer, parameter :: nx = 40, ny = 40 real(dp) :: data1(ny, nx), data2(ny, nx), data3(ny, nx), x(nx), y(ny) integer :: i, j real(dp), parameter :: pi = 3.14159265358979323846_dp .. GENERATED FROM PYTHON SOURCE LINES 16-17 Create a grid of x and y values .. GENERATED FROM PYTHON SOURCE LINES 19-26 .. code-block:: Fortran :dedent: 1 do i = 1, nx x(i) = -5.0_dp + 10.0_dp * real(i - 1, dp) / real(nx - 1, dp) end do do j = 1, ny y(j) = -5.0_dp + 10.0_dp * real(j - 1, dp) / real(ny - 1, dp) end do .. GENERATED FROM PYTHON SOURCE LINES 27-30 Create three different 2D data fields: the Gaussian :math:`e^{-(x^2 + y^2)/2}`, the product :math:`\sin x \cos y`, and the radial distance :math:`\sqrt{x^2 + y^2}` .. GENERATED FROM PYTHON SOURCE LINES 32-52 .. code-block:: Fortran :dedent: 1 ! Gaussian do j = 1, ny do i = 1, nx data1(j, i) = exp(-(x(i)**2 + y(j)**2) / 2.0_dp) end do end do ! Product of sinusoids do j = 1, ny do i = 1, nx data2(j, i) = sin(x(i)) * cos(y(j)) end do end do ! Radial distance do j = 1, ny do i = 1, nx data3(j, i) = sqrt(x(i)**2 + y(j)**2) end do end do .. GENERATED FROM PYTHON SOURCE LINES 53-54 Create a 1x3 subplot layout to display the three images side by side .. GENERATED FROM PYTHON SOURCE LINES 55-76 .. code-block:: Fortran call figure(figsize=[15.0_dp, 4.0_dp]) call subplot(1, 3, 1) call imshow(data1, cmap="viridis") call title("Gaussian") call colorbar() call subplot(1, 3, 2) call imshow(data2, cmap="plasma") call title("Sin(x) * Cos(y)") call colorbar() call subplot(1, 3, 3) call imshow(data3, cmap="cool") call title("Radial Distance") call colorbar() call savefig("multi_image.png") print *, "wrote multi_image.png" end program plot_multi_image .. image-sg:: /auto_gallery/images_contours_and_fields/images/sphx_glr_plot_multi_image_001.png :alt: plot multi image :srcset: /auto_gallery/images_contours_and_fields/images/sphx_glr_plot_multi_image_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none wrote multi_image.png .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.276 seconds) .. _sphx_glr_download_auto_gallery_images_contours_and_fields_plot_multi_image.f90: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Fortran source code: plot_multi_image.f90 ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_multi_image.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_