Errorbar Demo

Errorbar Demo

Source: errorbar_demo.f90

Demonstrates error bar plotting with both symmetric and asymmetric errors for scientific data visualization.

  • Symmetric error bars: Single error value for both directions
  • Asymmetric error bars: Different upper and lower error bounds
  • X and Y errors: Error bars on both axes
  • Visual customization: Cap size, line width, colors, markers
  • Multiple datasets: Comparing experimental data with different uncertainties
  • Scientific styling: Professional presentation for publications
! Basic symmetric errors
call fig%errorbar(x, y, yerr=yerr, label='Data with errors')

! Asymmetric errors
call fig%errorbar(x, y, yerr_lower=y_lower, yerr_upper=y_upper)

! Custom styling
call fig%errorbar(x, y, yerr=yerr, capsize=8.0_wp, &
                  elinewidth=2.0_wp, marker='o', color=[1.0, 0.0, 0.0])

The demo generates examples showing: - Basic error bars with measurement uncertainty - Multiple datasets with different error magnitudes - Custom styling and professional scientific presentation

Perfect for scientific plotting where uncertainty visualization is essential.

Files

  • errorbar_demo.f90 - Source code
  • Generated media in output/example/fortran/errorbar_demo/

Running

make example ARGS="errorbar_demo"

Output

Errorbar Asymmetric

errorbar_asymmetric.png

Text backend output


                    Symmetric Y Error Bars (from asymmetric)
Y values
+--------------------------------------------------------------------------------+
| 4.0                                                                            |
| |                                                                              |
| |                                                                              |
| |                                     -                 - --- Average errors   |
| 3.5                                   -                 -                      |
| |                                                                              |
| |                                     -                 -                      |
| 3.0                                                                      -     |
| |                    -                -                 -                      |
| |                                     -   -             -                -     |
| |                    -         -   -         -   -  -                    -     |
| 2.5                  -      -         -                 -                      |
| |                    -  -             -                 - -              -     |
| |                 -  -                                       -           -     |
| |                                     -                 -       -              |
| 2.0            -     -                -                            -     -     |
| |           -        -                                  -             -  -     |
| |        -                                              -                -     |
| |  -  -                                                                  -     |
| 1.5-                                                    -                -     |
| |  -                                                                           |
| |                                                                        -     |
| 1.0-                                                                           |
| |                                                                        -     |
| |                                                                        -     |
| |                                                                              |
| 0.5                                                                      -     |
| |                                                                        -     |
| +--+-------+--------+--------+--------+--------+--------+--------+-------+---- |
|   1.0     1.5      2.0      2.5      3.0      3.5      4.0      4.5     5.0    |
+--------------------------------------------------------------------------------+
                                    X values

Download text

Download PDF

Errorbar Basic X

errorbar_basic_x.png

Text backend output


                             Symmetric X Error Bars
Y values
+--------------------------------------------------------------------------------+
| 3                                                                              |
| |                                                                              |
| |                                                                              |
| |                 -- -- -                             --- Data with X errors   |
| |            - --        - --                                                  |
| 2         ----               -                                                 |
| |        -                     --                                              |
| |       -                        -                                             |
| |     --                         ----                                          |
| |  -- -                             -                                          |
| 1                                    -                                         |
| |                                      -                                       |
| |                                       -                                      |
| |                                       ----                                   |
| 0                                          -                                   |
| |                                           -                                  |
| |                                            -                                 |
| |                                             -                                |
| |                                              -                               |
| -1                                              -- -                           |
| |                                                 -                            |
| |                                                  -                           |
| |                                                   --                         |
| -2                                                    -                        |
| |                                                       -                      |
| |                                                      - --                    |
| |                                                           --                 |
| |                                                              -- -- -- --     |
| +-----------+--------------+--------------+--------------+--------------+----- |
| -3          2              4              6              8             10      |
+--------------------------------------------------------------------------------+
                                    X values

Download text

Download PDF

Errorbar Basic Y

errorbar_basic_y.png

Text backend output


                          Basic Symmetric Y Error Bars
Y values
+--------------------------------------------------------------------------------+
|                                                                                |
| |                                                                              |
| |                                                                              |
| 3                  -                                  --- Data with Y errors   |
| |                  -      -                                                    |
| |          -   - - -- --  -                                                    |
| 2          -- -    -     -- -                                                  |
| |        - -       -      -  --   -                                            |
| |      --  -              -     ---                                            |
| |  -  -                           -                                            |
| 1  --                             ---                                          |
| |  -                              -  -                                         |
| |  -                                   -- -                                    |
| |                                        --                                    |
| 0                                         --                                   |
| |                                         - -                                  |
| |                                            --                                |
| |                                              -- -                            |
| -1                                               --                            |
| |                                                 --                           |
| |                                                 - -                          |
| |                                                    --  -                     |
| -2                                                     ---                     |
| |                                                        - -     -       -     |
| |                                                        -   --  -       -     |
| |                                                        -      -- -- -- -     |
| -3                                                               -       -     |
| |                                                                -       -     |
| +---------+---------------+---------------+---------------+--------------+---- |
|           2               4               6               8             10     |
+--------------------------------------------------------------------------------+
                                    X values

Download text

Download PDF

Errorbar Combined

errorbar_combined.png

Text backend output


                          Combined X and Y Error Bars
Y values
+--------------------------------------------------------------------------------+
|                                                                                |
| |                                                                              |
| |                                                                              |
| 3                  -                                 --- Data with XY errors   |
| |                  -       -                                                   |
| |           -   - -- -- -  -                                                   |
| 2         - -- -   -     - --                                                  |
| |          --      -       - - -  -                                            |
| |       --  -              -    ---                                            |
| |   -  -                         -- -                                          |
| 1  -- -                           ---                                          |
| |   -                             -  -                                         |
| |   -                                  -- -                                    |
| |                                        --                                    |
| 0                                       - --                                   |
| |                                         - -                                  |
| |                                            -                                 |
| |                                             -- -                             |
| -1                                              --                             |
| |                                               ----                           |
| |                                                - -                           |
| |                                                   --   -                     |
| -2                                                    - --                     |
| |                                                      - --     -       -      |
| |                                                        -  --  -       -      |
| |                                                        -     -- -- -- --     |
| -3                                                              -       -      |
| |                                                               -       -      |
| +-----------+--------------+--------------+--------------+--------------+----- |
|             2              4              6              8             10      |
+--------------------------------------------------------------------------------+
                                    X values

Download text

Download PDF

Errorbar Custom

errorbar_custom.png

Text backend output


                       Customized Error Bars with Markers
Y values
+--------------------------------------------------------------------------------+
|                                                                                |
| |                                                                              |
| |                                                                              |
| 3                % %%                                     -o- Custom styling   |
| |                  %     %% %                                                  |
| |        % %%  % % o% %%  %                                                    |
| 2          o% %    %     %o %                                                  |
| |        % %     % %%     %  %%  %%%                                           |
| |      %%% %%            %% %   %%%                                            |
| | %%% %                           o                                            |
| 1  o%                             %%%                                          |
| |  %                             %%% %                                         |
| | %%%                                  %%%%%                                   |
| |                                        %%                                    |
| 0                                         o%                                   |
| |                                        %%%%                                  |
| |                                            %%                                |
| |                                              %% %%                           |
| -1                                               %%                            |
| |                                                 o%                           |
| |                                               % %%%                          |
| |                                                    %% %% %                   |
| -2                                                     %%%                     |
| |                                                        o %    %% %    %%%    |
| |                                                        %   %%  %       %     |
| |                                                       %% %    %o %% %% o     |
| -3                                                               %       %     |
| |                                                               %% %    %%%    |
| +---------+---------------+---------------+---------------+--------------+---- |
|           2               4               6               8             10     |
+--------------------------------------------------------------------------------+
                                    X values

Download text

Download PDF

Errorbar Scientific

errorbar_scientific.png

Text backend output


                        Scientific Data with Error Bars
Signal amplitude
+--------------------------------------------------------------------------------+
|                                                                                |
| |                                                                              |
| |                                                                              |
| 3.0-                                                                           |
| |  -                                                                           |
| |  #                                                                           |
| |  ---                                                                         |
| |     -    -                                                                   |
| |  -   --                                                                      |
| 2.5      --                                                                    |
| |          #--                                                                 |
| |            --    -                                                           |
| |          -   --                                                              |
| |                --#                                                           |
| 2.0                ---    -                                                    |
| |                  -  ---                                                      |
| |                        -#                                                    |
| |                          ----   -                                            |
| |                         -    --                                              |
| |                                -#---    -                                    |
| 1.5                                   ---                                      |
| |                                 -      -#--     -                            |
| |                                            -----#      -                     |
| |                                         -        -----         -             |
| |                                                 -     -#-----          -     |
| 1.0                                                      -     --#-----        |
| |                                                                -    ---#     |
| |   -#- Experimental data                                                -     |
| +--+--------+---------+---------+---------+---------+---------+--------+------ |
|   0.0      2.5       5.0       7.5      10.0      12.5      15.0     17.5      |
+--------------------------------------------------------------------------------+
                                    Time (s)

Download text

Download PDF