├── .github └── workflows │ ├── cmake.yml │ ├── doc-deployment.yml │ └── fpm.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake └── helper.cmake ├── configure └── CMakeLists.txt ├── dependencies ├── CMakeLists.txt ├── collections │ └── CMakeLists.txt ├── ferror │ └── CMakeLists.txt ├── forcolormap │ └── CMakeLists.txt ├── fstring │ └── CMakeLists.txt └── geompack │ └── CMakeLists.txt ├── doc ├── css │ ├── bootstrap.css │ ├── bootstrap.min.css │ ├── font-awesome.css │ ├── font-awesome.min.css │ ├── local.css │ └── pygments.css ├── favicon.png ├── fonts │ ├── FontAwesome.otf │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.svg │ ├── fontawesome-webfont.ttf │ ├── fontawesome-webfont.woff │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ └── glyphicons-halflings-regular.woff ├── index.html ├── interface │ ├── cm_get_string_result.html │ ├── get_string_result.html │ ├── operator(==).html │ ├── operator(SLASH=).html │ ├── pa_get_string_result.html │ ├── pd_get_string_result.html │ ├── simplify_polyline.html │ ├── spd_get_int_value.html │ ├── spd_get_string_result.html │ ├── spd_get_value.html │ ├── spd_set_value.html │ └── term_get_string_result.html ├── js │ ├── MathJax-config │ │ └── .gitignore │ ├── bootstrap.js │ ├── bootstrap.min.js │ ├── ie10-viewport-bug-workaround.js │ ├── jquery-2.1.3.min.js │ └── svg-pan-zoom.min.js ├── lists │ ├── files.html │ ├── modules.html │ ├── procedures.html │ └── types.html ├── module │ ├── fplot_arrow.html │ ├── fplot_colormap.html │ ├── fplot_colors.html │ ├── fplot_constants.html │ ├── fplot_core.html │ ├── fplot_core_routines.html │ ├── fplot_delaunay_tri_surface.html │ ├── fplot_errors.html │ ├── fplot_filled_plot_data.html │ ├── fplot_label.html │ ├── fplot_latex_terminal.html │ ├── fplot_legend.html │ ├── fplot_multiplot.html │ ├── fplot_plot.html │ ├── fplot_plot_2d.html │ ├── fplot_plot_3d.html │ ├── fplot_plot_axis.html │ ├── fplot_plot_bar.html │ ├── fplot_plot_data.html │ ├── fplot_plot_data_2d.html │ ├── fplot_plot_data_3d.html │ ├── fplot_plot_data_bar.html │ ├── fplot_plot_data_error_bars.html │ ├── fplot_plot_data_histogram.html │ ├── fplot_plot_data_tri_2d.html │ ├── fplot_plot_object.html │ ├── fplot_plot_polar.html │ ├── fplot_png_terminal.html │ ├── fplot_qt_terminal.html │ ├── fplot_simplify.html │ ├── fplot_stats_plots.html │ ├── fplot_surface_plot.html │ ├── fplot_surface_plot_data.html │ ├── fplot_terminal.html │ ├── fplot_tri_surface_plot_data.html │ ├── fplot_triangulations_delaunay_2d.html │ ├── fplot_vector_field_plot_data.html │ ├── fplot_windows_terminal.html │ └── fplot_wxt_terminal.html ├── proc │ ├── linspace.html │ ├── logspace.html │ ├── meshgrid.html │ ├── report_array_size_mismatch_error.html │ ├── report_file_create_error.html │ ├── report_matrix_size_mismatch_error.html │ └── report_memory_error.html ├── search.html ├── sourcefile │ ├── fplot_arrow.f90.html │ ├── fplot_colormap.f90.html │ ├── fplot_colors.f90.html │ ├── fplot_constants.f90.html │ ├── fplot_core.f90.html │ ├── fplot_core_routines.f90.html │ ├── fplot_delaunay_tri_surface.f90.html │ ├── fplot_errors.f90.html │ ├── fplot_filled_plot_data.f90.html │ ├── fplot_label.f90.html │ ├── fplot_latex_terminal.f90.html │ ├── fplot_legend.f90.html │ ├── fplot_multiplot.f90.html │ ├── fplot_plot.f90.html │ ├── fplot_plot_2d.f90.html │ ├── fplot_plot_3d.f90.html │ ├── fplot_plot_axis.f90.html │ ├── fplot_plot_bar.f90.html │ ├── fplot_plot_data.f90.html │ ├── fplot_plot_data_2d.f90.html │ ├── fplot_plot_data_3d.f90.html │ ├── fplot_plot_data_bar.f90.html │ ├── fplot_plot_data_error_bars.f90.html │ ├── fplot_plot_data_histogram.f90.html │ ├── fplot_plot_data_tri_2d.f90.html │ ├── fplot_plot_object.f90.html │ ├── fplot_plot_polar.f90.html │ ├── fplot_png_terminal.f90.html │ ├── fplot_qt_terminal.f90.html │ ├── fplot_simplify.f90.html │ ├── fplot_stats_plots.f90.html │ ├── fplot_surface_plot.f90.html │ ├── fplot_surface_plot_data.f90.html │ ├── fplot_terminal.f90.html │ ├── fplot_tri_surface_plot_data.f90.html │ ├── fplot_triangulations_delaunay_2d.f90.html │ ├── fplot_vector_field_plot_data.f90.html │ ├── fplot_windows_terminal.f90.html │ └── fplot_wxt_terminal.f90.html ├── src │ ├── fplot_arrow.f90 │ ├── fplot_colormap.f90 │ ├── fplot_colors.f90 │ ├── fplot_constants.f90 │ ├── fplot_core.f90 │ ├── fplot_core_routines.f90 │ ├── fplot_delaunay_tri_surface.f90 │ ├── fplot_errors.f90 │ ├── fplot_filled_plot_data.f90 │ ├── fplot_label.f90 │ ├── fplot_latex_terminal.f90 │ ├── fplot_legend.f90 │ ├── fplot_multiplot.f90 │ ├── fplot_plot.f90 │ ├── fplot_plot_2d.f90 │ ├── fplot_plot_3d.f90 │ ├── fplot_plot_axis.f90 │ ├── fplot_plot_bar.f90 │ ├── fplot_plot_data.f90 │ ├── fplot_plot_data_2d.f90 │ ├── fplot_plot_data_3d.f90 │ ├── fplot_plot_data_bar.f90 │ ├── fplot_plot_data_error_bars.f90 │ ├── fplot_plot_data_histogram.f90 │ ├── fplot_plot_data_tri_2d.f90 │ ├── fplot_plot_object.f90 │ ├── fplot_plot_polar.f90 │ ├── fplot_png_terminal.f90 │ ├── fplot_qt_terminal.f90 │ ├── fplot_simplify.f90 │ ├── fplot_stats_plots.f90 │ ├── fplot_surface_plot.f90 │ ├── fplot_surface_plot_data.f90 │ ├── fplot_terminal.f90 │ ├── fplot_tri_surface_plot_data.f90 │ ├── fplot_triangulations_delaunay_2d.f90 │ ├── fplot_vector_field_plot_data.f90 │ ├── fplot_windows_terminal.f90 │ └── fplot_wxt_terminal.f90 ├── tipuesearch │ ├── .DS_Store │ ├── img │ │ ├── .DS_Store │ │ ├── loader.gif │ │ └── search.png │ ├── tipuesearch.css │ ├── tipuesearch.js │ ├── tipuesearch.min.js │ ├── tipuesearch_content.js │ └── tipuesearch_set.js └── type │ ├── color.html │ ├── colormap.html │ ├── cool_colormap.html │ ├── correlation_plot.html │ ├── custom_colormap.html │ ├── delaunay_tri_2d.html │ ├── delaunay_tri_surface.html │ ├── earth_colormap.html │ ├── filled_plot_data.html │ ├── grey_colormap.html │ ├── hot_colormap.html │ ├── latex_terminal.html │ ├── legend.html │ ├── multiplot.html │ ├── parula_colormap.html │ ├── plot.html │ ├── plot_2d.html │ ├── plot_3d.html │ ├── plot_arrow.html │ ├── plot_axis.html │ ├── plot_bar.html │ ├── plot_data.html │ ├── plot_data_2d.html │ ├── plot_data_3d.html │ ├── plot_data_bar.html │ ├── plot_data_colored.html │ ├── plot_data_error_bars.html │ ├── plot_data_histogram.html │ ├── plot_data_tri_2d.html │ ├── plot_label.html │ ├── plot_object.html │ ├── plot_polar.html │ ├── png_terminal.html │ ├── qt_terminal.html │ ├── rainbow_colormap.html │ ├── scatter_plot_data.html │ ├── surface_plot.html │ ├── surface_plot_data.html │ ├── terminal.html │ ├── tri_surface_plot_data.html │ ├── vector_field_plot_data.html │ ├── windows_terminal.html │ ├── wxt_terminal.html │ ├── x_axis.html │ ├── y2_axis.html │ ├── y_axis.html │ └── z_axis.html ├── docs.md ├── examples ├── CMakeLists.txt ├── arrow_example.f90 ├── clear_plot_example.f90 ├── colored_vector_plot_example.f90 ├── correlation_plot_example.f90 ├── custom_colormap_example.f90 ├── data_dependent_colors_2d.f90 ├── data_dependent_colors_3d.f90 ├── error_bar_example.f90 ├── fill_between_curves_example.f90 ├── filled_curve_example.f90 ├── generic_2d_plot.f90 ├── generic_3d_plot.f90 ├── histogram_example.f90 ├── latex_plot_example.f90 ├── legend_example.f90 ├── log_scaling_example.f90 ├── margins_example.f90 ├── meson.build ├── multiplot_example_1.f90 ├── multiplot_example_2.f90 ├── multiplot_save_to_file_example.f90 ├── plot_label_example.f90 ├── png_plot_example.f90 ├── png_plot_example_2.f90 ├── polar_plot_example.f90 ├── save_to_file_example.f90 ├── secondary_y_axis_example.f90 ├── square_axis_example.f90 ├── surface_plot_example.f90 ├── surface_plot_example_2.f90 ├── triangle_mesh_surface_example.f90 ├── triangulation_2d_example.f90 ├── triangulation_2d_location_example.f90 ├── variable_point_size_2d_example.f90 ├── variable_point_size_3d_example.f90 ├── vector_plot_example.f90 ├── wireframe_surface_example.f90 └── zero_axis_example.f90 ├── fpm.toml ├── images ├── custom_colormap.png ├── default_2d_example.png ├── example_2d_log_scaling_1.png ├── example_2d_plot_1.png ├── example_2d_plot_2.png ├── example_data_depend_color_2d.png ├── example_data_depend_color_3d.png ├── example_delaunay_2d_1.png ├── example_delaunay_2d_2a.png ├── example_delaunay_2d_2b.png ├── example_label_plot.png ├── example_multiplot_1.png ├── example_multiplot_2.png ├── example_multiplot_log_scaled.png ├── example_plot.png ├── example_plot_2d_1.png ├── example_plot_2d_2.png ├── example_plot_2d_3.png ├── example_plot_3d_1.png ├── example_plot_3d_offset_1.png ├── example_plot_from_file.png ├── example_plot_legend_out.png ├── example_plot_with_label_1.png ├── example_plot_y2_axis_1.png ├── example_surf_plot_1.png ├── example_surface_plot.png ├── example_surface_plot_2.png ├── example_surface_plot_cool.png ├── example_surface_plot_default.png ├── example_surface_plot_earth.png ├── example_surface_plot_grey.png ├── example_surface_plot_horizontal.png ├── example_surface_plot_hot.png ├── example_surface_plot_lighting_1.png ├── example_surface_plot_lighting_2.png ├── example_surface_plot_no_border.png ├── example_surface_plot_no_tics.png ├── example_surface_plot_parula.png ├── example_surface_plot_with_contour_1.png ├── example_tri_surf_1.png ├── example_wireframe_surface_plot.png ├── example_x_errorbars_1.png ├── example_xy_errorbars_1.png ├── example_xy_errorbox_1.png ├── example_y_errorbars_1.png ├── filled_example_1.png ├── filled_example_2.png ├── histogram_example_1.png ├── polar_example_1.png ├── polar_example_2.png ├── square_2d_example.png ├── surface_example_w_cb_label.png ├── surface_plot_hidden_lines_1.png ├── vector_plot_1.png └── vector_plot_2.png ├── meson.build ├── packages.json ├── src ├── CMakeLists.txt ├── fplot_arrow.f90 ├── fplot_colormap.f90 ├── fplot_colors.f90 ├── fplot_constants.f90 ├── fplot_core.f90 ├── fplot_core_routines.f90 ├── fplot_delaunay_tri_surface.f90 ├── fplot_errors.f90 ├── fplot_filled_plot_data.f90 ├── fplot_label.f90 ├── fplot_latex_terminal.f90 ├── fplot_legend.f90 ├── fplot_multiplot.f90 ├── fplot_plot.f90 ├── fplot_plot_2d.f90 ├── fplot_plot_3d.f90 ├── fplot_plot_axis.f90 ├── fplot_plot_bar.f90 ├── fplot_plot_data.f90 ├── fplot_plot_data_2d.f90 ├── fplot_plot_data_3d.f90 ├── fplot_plot_data_bar.f90 ├── fplot_plot_data_error_bars.f90 ├── fplot_plot_data_histogram.f90 ├── fplot_plot_data_tri_2d.f90 ├── fplot_plot_object.f90 ├── fplot_plot_polar.f90 ├── fplot_png_terminal.f90 ├── fplot_qt_terminal.f90 ├── fplot_simplify.f90 ├── fplot_stats_plots.f90 ├── fplot_surface_plot.f90 ├── fplot_surface_plot_data.f90 ├── fplot_terminal.f90 ├── fplot_tri_surface_plot_data.f90 ├── fplot_triangulations_delaunay_2d.f90 ├── fplot_vector_field_plot_data.f90 ├── fplot_windows_terminal.f90 ├── fplot_wxt_terminal.f90 └── meson.build ├── subprojects ├── fcore.wrap └── ferror.wrap └── test ├── CMakeLists.txt ├── fortran_test_helper └── CMakeLists.txt ├── fplot_3d_test.f90 ├── fplot_arrow_test.f90 └── fplot_test.f90 /.github/workflows/cmake.yml: -------------------------------------------------------------------------------- 1 | name: CMake 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | env: 10 | BUILD_TYPE: Release 11 | 12 | jobs: 13 | test: 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | os: [ubuntu-latest, macos-latest] 19 | toolchain: 20 | - {compiler: gcc, version: 11} 21 | - {compiler: intel-classic, version: '2021.9'} 22 | include: 23 | - os: ubuntu-latest 24 | toolchain: {compiler: intel, version: '2023.2'} 25 | 26 | steps: 27 | - uses: fortran-lang/setup-fortran@v1.6.1 28 | id: setup-fortran 29 | with: 30 | compiler: ${{ matrix.toolchain.compiler }} 31 | version: ${{ matrix.toolchain.version }} 32 | 33 | - run: ${{ env.FC }} --version 34 | env: 35 | FC: ${{ steps.setup-fortran.outputs.fc }} 36 | CC: ${{ steps.setup-fortran.outputs.cc }} 37 | 38 | - uses: actions/checkout@v3 39 | 40 | - name: Configure CMake 41 | run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_Fortran_COMPILER=${{ env.FC }} -DBUILD_TESTING=TRUE 42 | 43 | - name: Build with CMake 44 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} 45 | 46 | - name: Test with CMake 47 | working-directory: ${{github.workspace}}/build 48 | run: ctest -C ${{env.BUILD_TYPE}} 49 | -------------------------------------------------------------------------------- /.github/workflows/doc-deployment.yml: -------------------------------------------------------------------------------- 1 | name: doc-deployment 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build-and-deploy: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: actions/setup-python@v1 11 | with: 12 | python-version: '3.x' 13 | 14 | - name: Install dependencies 15 | run: pip install -v ford==6.1.17 16 | 17 | - name: Build Documentation 18 | run: ford docs.md 19 | 20 | - uses: JamesIves/github-pages-deploy-action@3.7.1 21 | if: github.event_name == 'push' && github.repository == 'jchristopherson/fplot' && ( startsWith( github.ref, 'refs/tags/' ) || github.ref == 'refs/heads/master' ) 22 | with: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | BRANCH: gh-pages 25 | FOLDER: doc 26 | CLEAN: true 27 | -------------------------------------------------------------------------------- /.github/workflows/fpm.yml: -------------------------------------------------------------------------------- 1 | name: fpm 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | gcc-build: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | fail-fast: false 10 | matrix: 11 | os: [ubuntu-latest] 12 | gcc_v: [12] # Version of GFortran we want to use. 13 | include: 14 | - os: ubuntu-latest 15 | os-arch: linux-x86_64 16 | 17 | env: 18 | FC: gfortran 19 | GCC_V: ${{ matrix.gcc_v }} 20 | 21 | steps: 22 | - name: Checkout code 23 | uses: actions/checkout@v1 24 | 25 | - name: Install GFortran Linux 26 | if: contains(matrix.os, 'ubuntu') 27 | run: | 28 | sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \ 29 | --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \ 30 | --slave /usr/bin/gcov gcov /usr/bin/gcov-${GCC_V} 31 | 32 | - name: Install BLAS & LAPACK 33 | if: contains(matrix.os, 'ubuntu') 34 | run: | 35 | sudo apt-get update 36 | sudo apt-get install libopenblas-dev liblapack-dev 37 | 38 | - name: Install fpm 39 | uses: fortran-lang/setup-fpm@v5 40 | with: 41 | fpm-version: 'v0.10.1' 42 | 43 | - name: Build LINALG 44 | run: | 45 | gfortran --version 46 | fpm build 47 | 48 | - name: Run tests 49 | run: | 50 | gfortran --version 51 | fpm test 52 | 53 | msys2-build: 54 | runs-on: windows-latest 55 | defaults: 56 | run: 57 | shell: msys2 {0} 58 | 59 | steps: 60 | - uses: actions/checkout@v2 61 | - uses: msys2/setup-msys2@v2 62 | with: 63 | msystem: MINGW64 64 | update: true 65 | path-type: inherit 66 | install: | 67 | mingw-w64-x86_64-gcc-fortran 68 | mingw-w64-x86_64-fpm 69 | mingw-w64-x86_64-openblas 70 | mingw-w64-x86_64-lapack 71 | 72 | - name: fpm build 73 | run: | 74 | gfortran --version 75 | fpm --version 76 | fpm build 77 | 78 | - name: fpm test 79 | run: | 80 | fpm test 81 | 82 | # intel-build: 83 | # runs-on: ubuntu-latest 84 | # strategy: 85 | # fail-fast: false 86 | 87 | # env: 88 | # FPM_FC: ifx 89 | # FC: ifx 90 | 91 | # steps: 92 | # - name: Checkout code 93 | # uses: actions/checkout@v3 94 | 95 | # - name: Add Intel repository (Linux) 96 | # run: | 97 | # wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB 98 | # sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB 99 | # rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB 100 | # echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list 101 | # sudo apt-get update 102 | 103 | # - name: Install Intel oneAPI compiler (Linux) 104 | # run: | 105 | # sudo apt-get install intel-oneapi-compiler-fortran 106 | 107 | # - name: Setup Intel oneAPI environment 108 | # run: | 109 | # source /opt/intel/oneapi/setvars.sh 110 | # printenv >> $GITHUB_ENV 111 | 112 | # - name: Install MKL 113 | # run: | 114 | # sudo apt-get update 115 | # sudo apt-get -y install intel-mkl 116 | # sudo apt update 117 | # sudo apt -y install intel-mkl 118 | 119 | # - name: Install fpm 120 | # uses: fortran-lang/setup-fpm@v3 121 | # with: 122 | # fpm-version: 'v0.8.2' 123 | 124 | # - name: fpm build 125 | # run: | 126 | # ifx --version 127 | # fpm --version 128 | # fpm build --profile debug --flag "-warn nointerfaces" 129 | 130 | # - name: fpm test 131 | # run: | 132 | # fpm test --profile debug --flag "-warn nointerfaces" -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Directories 35 | bin/ 36 | lib/ 37 | build/ 38 | latex/ 39 | 40 | 41 | # CMake Stuff 42 | .cmaketools.json 43 | CMakeCache.txt 44 | CMakeFiles 45 | CMakeScripts 46 | Testing 47 | Makefile 48 | cmake_install.cmake 49 | install_manifest.txt 50 | CTestTestfile.cmake 51 | 52 | # Misc. Stuff 53 | *.bin 54 | *.plt 55 | *.json -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # CMake project file for FPLOT 2 | cmake_minimum_required(VERSION 3.24) 3 | project( 4 | fplot 5 | LANGUAGES Fortran 6 | VERSION 1.8.0 7 | ) 8 | 9 | # Get helper macros and functions 10 | include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake") 11 | 12 | # Confgiure everything 13 | add_subdirectory(configure) 14 | 15 | # Locate Dependencies 16 | add_subdirectory(dependencies) 17 | 18 | # Source 19 | add_subdirectory(src) 20 | add_fortran_library( 21 | ${PROJECT_NAME} 22 | ${PROJECT_INCLUDE_DIR} 23 | ${CMAKE_INSTALL_INCLUDEDIR} 24 | ${PROJECT_VERSION} 25 | ${PROJECT_VERSION_MAJOR} 26 | ${FPLOT_SOURCES} 27 | ) 28 | link_library(${PROJECT_NAME} ${ferror_LIBRARY} ${ferror_INCLUDE_DIR}) 29 | link_library(${PROJECT_NAME} ${fstring_LIBRARY} ${fstring_INCLUDE_DIR}) 30 | link_library(${PROJECT_NAME} ${collections_LIBRARY} ${collections_INCLUDE_DIR}) 31 | link_library(${PROJECT_NAME} ${geompack_LIBRARY} ${geompack_INCLUDE_DIR}) 32 | link_library(${PROJECT_NAME} ${forcolormap_LIBRARY} ${forcolormap_INCLUDE_DIR}) 33 | 34 | # ------------------------------------------------------------------------------ 35 | # EXAMPLES 36 | # ------------------------------------------------------------------------------ 37 | option(BUILD_FPLOT_EXAMPLES "Build FPLOT examples?" OFF) 38 | if (BUILD_FPLOT_EXAMPLES) 39 | # Inform the user we're building the examples 40 | message(STATUS "Building FPLOT examples.") 41 | 42 | # Build the examples 43 | add_subdirectory(examples) 44 | endif() 45 | 46 | # ------------------------------------------------------------------------------ 47 | # TESTING 48 | # ------------------------------------------------------------------------------ 49 | option(BUILD_TESTING "Build tests") 50 | include(CTest) 51 | message(STATUS "Build tests: ${BUILD_TESTING}") 52 | if (BUILD_TESTING) 53 | enable_testing() 54 | add_subdirectory(test) 55 | endif() -------------------------------------------------------------------------------- /cmake/helper.cmake: -------------------------------------------------------------------------------- 1 | # helper.cmake 2 | # 3 | # A collection of macros and functions making life with CMake and Fortran a 4 | # bit simpler. 5 | 6 | # Use to include and export headers 7 | function(include_headers lib dir install_dir) 8 | target_include_directories( 9 | ${lib} 10 | INTERFACE 11 | $ 12 | $ 13 | ) 14 | endfunction() 15 | 16 | # Use instead of add_library. 17 | function(add_fortran_library lib_name mod_dir include_install_dir version major) 18 | add_library(${lib_name} ${ARGN}) 19 | set_target_properties( 20 | ${lib_name} 21 | PROPERTIES 22 | POSITION_INDEPENDENT_CODE TRUE 23 | OUTPUT_NAME ${lib_name} 24 | VERSION ${version} 25 | SOVERSION ${major} 26 | Fortran_MODULE_DIRECTORY ${include_install_dir} 27 | ) 28 | target_include_directories( 29 | ${lib_name} 30 | PUBLIC 31 | $ 32 | $ 33 | ) 34 | endfunction() 35 | 36 | # Installs the library 37 | function(install_library lib_name lib_install_dir bin_install_dir mod_dir install_dir) 38 | install( 39 | TARGETS ${lib_name} 40 | EXPORT ${lib_name}Targets 41 | RUNTIME DESTINATION ${bin_install_dir} 42 | LIBRARY DESTINATION ${lib_install_dir} 43 | ARCHIVE DESTINATION ${lib_install_dir} 44 | INCLUDES DESTINATION ${install_dir}/include 45 | ) 46 | install( 47 | DIRECTORY ${mod_dir} 48 | DESTINATION ${install_dir} 49 | ) 50 | endfunction() 51 | 52 | # Install the documentation files 53 | function(install_documentation doc_dir install_dir) 54 | install( 55 | DIRECTORY ${doc_dir} 56 | DESTINATION ${install_dir} 57 | ) 58 | endfunction() 59 | 60 | # Links the supplied library 61 | function(link_library targ lib include_dir) 62 | target_link_libraries(${targ} PRIVATE ${lib}) 63 | target_include_directories(${targ} PUBLIC $) 64 | endfunction() 65 | 66 | # ------------------------------------------------------------------------------ 67 | # Helpful Macros 68 | macro(print_all_variables) 69 | message(STATUS "---------- CURRENTLY DEFINED VARIABLES -----------") 70 | get_cmake_property(varNames VARIABLES) 71 | foreach(varName ${varNames}) 72 | message(STATUS ${varName} = ${${varName}}) 73 | endforeach() 74 | message(STATUS "---------- END ----------") 75 | endmacro() -------------------------------------------------------------------------------- /configure/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Get the macros and functions we'll need 2 | include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake") 3 | 4 | # Set a default build type if none was specified 5 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 6 | message(STATUS "Setting build type to 'Release' as none was specified.") 7 | set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) 8 | # Set the possible values of build type for cmake-gui 9 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release") 10 | endif() 11 | 12 | # By default, static library 13 | option(BUILD_SHARED_LIBS "Build shared libraries" OFF) 14 | 15 | # Export all symbols on Windows when building libraries 16 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) 17 | 18 | # Utilize the GNU installation structure 19 | include(GNUInstallDirs) 20 | 21 | # Locate the local include directory 22 | set(PROJECT_INCLUDE_DIR ${PROJECT_BINARY_DIR}/include) 23 | set(PROJECT_INCLUDE_DIR ${PROJECT_INCLUDE_DIR} PARENT_SCOPE) -------------------------------------------------------------------------------- /dependencies/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Get FERROR 2 | add_subdirectory(ferror) 3 | set(ferror_LIBRARY ${ferror_LIBRARY} PARENT_SCOPE) 4 | set(ferror_INCLUDE_DIR ${ferror_INCLUDE_DIR} PARENT_SCOPE) 5 | 6 | # Get FSTRING 7 | add_subdirectory(fstring) 8 | set(fstring_LIBRARY ${fstring_LIBRARY} PARENT_SCOPE) 9 | set(fstring_INCLUDE_DIR ${fstring_INCLUDE_DIR} PARENT_SCOPE) 10 | 11 | # Get COLLECTIONS 12 | add_subdirectory(collections) 13 | set(collections_LIBRARY ${collections_LIBRARY} PARENT_SCOPE) 14 | set(collections_INCLUDE_DIR ${collections_INCLUDE_DIR} PARENT_SCOPE) 15 | 16 | # Get GEOMPACK 17 | add_subdirectory(geompack) 18 | set(geompack_LIBRARY ${geompack_LIBRARY} PARENT_SCOPE) 19 | set(geompack_INCLUDE_DIR ${geompack_INCLUDE_DIR} PARENT_SCOPE) 20 | 21 | # Get FORCOLORMAP 22 | add_subdirectory(forcolormap) 23 | set(forcolormap_LIBRARY ${forcolormap_LIBRARY} PARENT_SCOPE) 24 | set(forcolormap_INCLUDE_DIR ${forcolormap_INCLUDE_DIR} PARENT_SCOPE) 25 | -------------------------------------------------------------------------------- /dependencies/collections/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Get the macros and functions we'll need 2 | include(FetchContent) 3 | 4 | # Fetch the proper content 5 | FetchContent_Declare( 6 | collections 7 | GIT_REPOSITORY "https://github.com/jchristopherson/collections" 8 | GIT_TAG main 9 | ) 10 | 11 | FetchContent_MakeAvailable(collections) 12 | 13 | set(collections_INCLUDE_DIR ${collections_BINARY_DIR}/include) 14 | set(collections_INCLUDE_DIR ${collections_INCLUDE_DIR} PARENT_SCOPE) 15 | 16 | # Make a parent-scope variable for the library 17 | set(collections_LIBRARY collections) 18 | set(collections_LIBRARY ${collections_LIBRARY} PARENT_SCOPE) 19 | -------------------------------------------------------------------------------- /dependencies/ferror/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(FetchContent) 2 | 3 | # Fetch the proper content 4 | FetchContent_Declare( 5 | ferror 6 | GIT_REPOSITORY "https://github.com/jchristopherson/ferror" 7 | ) 8 | FetchContent_MakeAvailable(ferror) 9 | 10 | set(ferror_INCLUDE_DIR ${ferror_BINARY_DIR}/include) 11 | configure_file( 12 | "${ferror_SOURCE_DIR}/include/ferror.h" 13 | "${ferror_INCLUDE_DIR}/ferror.h" 14 | COPYONLY 15 | ) 16 | set(ferror_LIBRARY ferror) 17 | set(ferror_INCLUDE_DIR ${ferror_INCLUDE_DIR} PARENT_SCOPE) 18 | set(ferror_LIBRARY ${ferror_LIBRARY} PARENT_SCOPE) 19 | -------------------------------------------------------------------------------- /dependencies/forcolormap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Get the macros and functions we'll need 2 | include(FetchContent) 3 | 4 | # Fetch the proper content 5 | FetchContent_Declare( 6 | forcolormap 7 | GIT_REPOSITORY "https://github.com/vmagnin/forcolormap" 8 | GIT_TAG main 9 | ) 10 | 11 | FetchContent_MakeAvailable(forcolormap) 12 | 13 | set(forcolormap_INCLUDE_DIR ${forcolormap_BINARY_DIR}/include) 14 | set(forcolormap_INCLUDE_DIR ${forcolormap_INCLUDE_DIR} PARENT_SCOPE) 15 | 16 | # Make a parent-scope variable for the library 17 | set(forcolormap_LIBRARY forcolormap) 18 | set(forcolormap_LIBRARY ${forcolormap_LIBRARY} PARENT_SCOPE) 19 | -------------------------------------------------------------------------------- /dependencies/fstring/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Get the macros and functions we'll need 2 | include(FetchContent) 3 | 4 | # Fetch the proper content 5 | FetchContent_Declare( 6 | fstring 7 | GIT_REPOSITORY "https://github.com/jchristopherson/fstring" 8 | GIT_TAG main 9 | ) 10 | 11 | FetchContent_MakeAvailable(fstring) 12 | 13 | set(fstring_INCLUDE_DIR ${fstring_BINARY_DIR}/include) 14 | set(fstring_INCLUDE_DIR ${fstring_INCLUDE_DIR} PARENT_SCOPE) 15 | 16 | # Make a parent-scope variable for the library 17 | set(fstring_LIBRARY fstring) 18 | set(fstring_LIBRARY ${fstring_LIBRARY} PARENT_SCOPE) 19 | -------------------------------------------------------------------------------- /dependencies/geompack/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Get the macros and functions we'll need 2 | include(FetchContent) 3 | 4 | # Fetch the proper content 5 | FetchContent_Declare( 6 | geompack 7 | GIT_REPOSITORY "https://github.com/jchristopherson/geompack" 8 | GIT_TAG main 9 | ) 10 | 11 | FetchContent_MakeAvailable(geompack) 12 | 13 | set(geompack_INCLUDE_DIR ${geompack_BINARY_DIR}/include) 14 | set(geompack_INCLUDE_DIR ${geompack_INCLUDE_DIR} PARENT_SCOPE) 15 | 16 | # Make a parent-scope variable for the library 17 | set(geompack_LIBRARY geompack) 18 | set(geompack_LIBRARY ${geompack_LIBRARY} PARENT_SCOPE) 19 | -------------------------------------------------------------------------------- /doc/css/local.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 70px; 3 | } 4 | table.nostretch { 5 | width=100% 6 | } 7 | .nostretch td { 8 | class='block' 9 | } 10 | .nostretch tr td{ 11 | width:1%; 12 | white-space:nowrap; 13 | } 14 | 15 | html { 16 | scroll-padding-top: 70px; 17 | } 18 | 19 | ol.hierarchy { 20 | min-height: 40px; 21 | background-color: #f5f5f5; 22 | border: 1px solid #e3e3e3; 23 | border-radius: 3px; 24 | -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); 25 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); 26 | } 27 | 28 | .smallcaps { 29 | font-variant: small-caps; 30 | } 31 | .well .sidebar { 32 | padding: 8px 0 33 | } 34 | .sidebar a { 35 | padding: 0px,0px,0px,0px 36 | } 37 | .varlist>tbody>tr>td { 38 | padding-left: 3px; 39 | padding-right: 3px; 40 | } 41 | .varlist>tbody>tr>td:first-child, .varlist>thead>tr>td:first-child { 42 | padding-left: 8px; 43 | } 44 | .varlist>tbody>td>td:last-child, .varlist>thead>tr>td:last-child { 45 | padding-right: 8px; 46 | } 47 | 48 | .highlight pre { 49 | overflow-x: auto; 50 | overflow-wrap: normal; 51 | white-space: pre 52 | } 53 | 54 | /* .hl is for when line numbers are included, .highlight is for all 55 | other cases. */ 56 | .hl pre { 57 | counter-reset: line-numbering; 58 | overflow-x: auto; 59 | overflow-wrap: normal; 60 | white-space: pre; 61 | padding: 0; 62 | padding-right: 9.5px; 63 | overflow-y: hidden; 64 | padding-bottom: 9.5px; 65 | } 66 | 67 | .hl pre a::before { 68 | content: counter(line-numbering); 69 | counter-increment: line-numbering; 70 | padding-right: 0.7em; /* space after numbers */ 71 | margin-top: 4.5em; 72 | width: 60px; 73 | text-align: right; 74 | opacity: 0.7; 75 | display: inline-block; 76 | color: #aaa; 77 | background: #eee; 78 | margin-right: 10px; 79 | border-right: 1px solid #ccc; 80 | -webkit-touch-callout: none; 81 | -webkit-user-select: none; 82 | -khtml-user-select: none; 83 | -moz-user-select: none; 84 | -ms-user-select: none; 85 | user-select: none; 86 | } 87 | 88 | .hl pre a:first-of-type::before { 89 | padding-top: 9.5px; 90 | } 91 | 92 | .hl pre a:last-of-type::before { 93 | padding-bottom: 9.5px; 94 | } 95 | 96 | .hl pre a:only-of-type::before { 97 | padding: 9.5px; 98 | } 99 | 100 | .hl pre a { 101 | display: inline-block; 102 | height: 4.5em; 103 | margin: -4.5em 0 0; 104 | } 105 | .codesum h3 { 106 | margin-top: 2px; 107 | margin-bottom: 2px; 108 | } 109 | 110 | h1.inline, h2.inline, h3.inline { 111 | display: inline; 112 | } 113 | 114 | .depwarn { 115 | float: right; 116 | } 117 | 118 | .anchor { 119 | position: absolute; 120 | margin: -4.5em; 121 | visibility:hidden; 122 | } 123 | 124 | .alert { 125 | margin-left: 5px; 126 | margin-right: 5px; 127 | margin-top: 5px; 128 | } 129 | 130 | div.toc { 131 | font-size: 14.73px; 132 | padding-left: 0px; 133 | padding-right: 0px; 134 | } 135 | 136 | div.toc a { 137 | padding-left: 20px; 138 | padding-right: 20px; 139 | margin-right: 15px; 140 | padding-top: 5px; 141 | padding-bottom: 5px; 142 | } 143 | 144 | div.toc li { 145 | font-size: 0.95em; 146 | padding-left: 15px; 147 | } 148 | 149 | div.toc li.title { 150 | font-size: 1em; 151 | } 152 | 153 | div.toc hr { 154 | margin-top: 12px; 155 | margin-bottom: 10px; 156 | } 157 | 158 | .in-well { 159 | padding: 0px 0px; 160 | margin-bottom: 0px; 161 | float:right; 162 | } 163 | 164 | table tr.submod>td { 165 | border-top: none; 166 | font-size: 13.5px; 167 | } 168 | 169 | .graph-help { 170 | font-size: 10px; 171 | } 172 | 173 | .depgraph { 174 | width: 100%; 175 | max-width: 1140px; 176 | } 177 | 178 | #sidebar a { 179 | white-space: nowrap; 180 | overflow: hidden; 181 | text-overflow: ellipsis; 182 | } 183 | 184 | .highlighttable { 185 | width: auto; 186 | table-layout: fixed; 187 | } 188 | 189 | ul.checklist { 190 | list-style-type: none; 191 | } 192 | 193 | ul.checklist input[type="checkbox"] { 194 | margin-left: -20.8px; 195 | margin-right: 4.55px; 196 | } 197 | 198 | .gitter-chat-embed { 199 | z-index: 100000; 200 | } 201 | 202 | table.graph { 203 | text-align: center; 204 | } 205 | 206 | 207 | .graph td.root { 208 | border:2px solid black; 209 | padding:10px; 210 | } 211 | 212 | .graph td.triangle-right:after { 213 | content: ""; 214 | display: block; 215 | border-top: 7px solid transparent; 216 | border-bottom: 7px solid transparent; 217 | border-left: 7px solid black; 218 | } 219 | 220 | .graph td.triangle-left:after { 221 | content: ""; 222 | display: block; 223 | border-top: 7px solid transparent; 224 | border-bottom: 7px solid transparent; 225 | border-right: 7px solid black; 226 | } 227 | 228 | .graph td.node { 229 | color: white; 230 | padding:10px; 231 | border-style: solid; 232 | border-width: 3px 0px 3px 0px; 233 | border-color: white; 234 | } 235 | 236 | .graph td.node a{ 237 | color: white; 238 | } 239 | 240 | .graph td.dashedText, 241 | .graph td.solidText { 242 | padding: 0px 10px 0px 10px; 243 | min-width: 40px; 244 | color: black; 245 | border-color: black; 246 | } 247 | 248 | .graph td.dashedText { 249 | border-bottom-style: dashed; 250 | } 251 | 252 | .graph td.solidText { 253 | border-bottom-style: solid; 254 | } 255 | 256 | .graph td.dashedBottom, 257 | .graph td.dashedTop, 258 | .graph td.solidTop, 259 | .graph td.solidBottom { 260 | min-width: 40px; 261 | color: transparent; 262 | border-color: black; 263 | } 264 | 265 | .graph td.dashedBottom { 266 | border-bottom-style: dashed; 267 | } 268 | 269 | .graph td.dashedTop { 270 | border-top-style: dashed; 271 | } 272 | 273 | .graph td.solidBottom { 274 | border-bottom-style: solid; 275 | } 276 | 277 | .graph td.solidTop { 278 | border-top-style: solid; 279 | } 280 | 281 | /* Ensure tables in Pages don't collapse horizontally */ 282 | td, th { 283 | padding-right: 10px; 284 | } 285 | -------------------------------------------------------------------------------- /doc/css/pygments.css: -------------------------------------------------------------------------------- 1 | pre .hll { background-color: #ffffcc } 2 | pre .c { color: #408080; font-style: italic } /* Comment */ 3 | pre .err { border: 1px solid #FF0000 } /* Error */ 4 | pre .k { color: #008000; font-weight: bold } /* Keyword */ 5 | pre .o { color: #666666 } /* Operator */ 6 | pre .cm { color: #408080; font-style: italic } /* Comment.Multiline */ 7 | pre .cp { color: #BC7A00 } /* Comment.Preproc */ 8 | pre .c1 { color: #408080; font-style: italic } /* Comment.Single */ 9 | pre .cs { color: #408080; font-style: italic } /* Comment.Special */ 10 | pre .gd { color: #A00000 } /* Generic.Deleted */ 11 | pre .ge { font-style: italic } /* Generic.Emph */ 12 | pre .gr { color: #FF0000 } /* Generic.Error */ 13 | pre .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 14 | pre .gi { color: #00A000 } /* Generic.Inserted */ 15 | pre .go { color: #888888 } /* Generic.Output */ 16 | pre .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ 17 | pre .gs { font-weight: bold } /* Generic.Strong */ 18 | pre .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 19 | pre .gt { color: #0044DD } /* Generic.Traceback */ 20 | pre .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ 21 | pre .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ 22 | pre .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ 23 | pre .kp { color: #008000 } /* Keyword.Pseudo */ 24 | pre .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ 25 | pre .kt { color: #B00040 } /* Keyword.Type */ 26 | pre .m { color: #666666 } /* Literal.Number */ 27 | pre .s { color: #BA2121 } /* Literal.String */ 28 | pre .na { color: #7D9029 } /* Name.Attribute */ 29 | pre .nb { color: #008000 } /* Name.Builtin */ 30 | pre .nc { color: #0000FF; font-weight: bold } /* Name.Class */ 31 | pre .no { color: #880000 } /* Name.Constant */ 32 | pre .nd { color: #AA22FF } /* Name.Decorator */ 33 | pre .ni { color: #999999; font-weight: bold } /* Name.Entity */ 34 | pre .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ 35 | pre .nf { color: #0000FF } /* Name.Function */ 36 | pre .nl { color: #A0A000 } /* Name.Label */ 37 | pre .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ 38 | pre .nt { color: #008000; font-weight: bold } /* Name.Tag */ 39 | pre .nv { color: #19177C } /* Name.Variable */ 40 | pre .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ 41 | pre .w { color: #bbbbbb } /* Text.Whitespace */ 42 | pre .mf { color: #666666 } /* Literal.Number.Float */ 43 | pre .mh { color: #666666 } /* Literal.Number.Hex */ 44 | pre .mi { color: #666666 } /* Literal.Number.Integer */ 45 | pre .mo { color: #666666 } /* Literal.Number.Oct */ 46 | pre .sb { color: #BA2121 } /* Literal.String.Backtick */ 47 | pre .sc { color: #BA2121 } /* Literal.String.Char */ 48 | pre .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ 49 | pre .s2 { color: #BA2121 } /* Literal.String.Double */ 50 | pre .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ 51 | pre .sh { color: #BA2121 } /* Literal.String.Heredoc */ 52 | pre .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ 53 | pre .sx { color: #008000 } /* Literal.String.Other */ 54 | pre .sr { color: #BB6688 } /* Literal.String.Regex */ 55 | pre .s1 { color: #BA2121 } /* Literal.String.Single */ 56 | pre .ss { color: #19177C } /* Literal.String.Symbol */ 57 | pre .bp { color: #008000 } /* Name.Builtin.Pseudo */ 58 | pre .vc { color: #19177C } /* Name.Variable.Class */ 59 | pre .vg { color: #19177C } /* Name.Variable.Global */ 60 | pre .vi { color: #19177C } /* Name.Variable.Instance */ 61 | pre .il { color: #666666 } /* Literal.Number.Integer.Long */ 62 | -------------------------------------------------------------------------------- /doc/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/favicon.png -------------------------------------------------------------------------------- /doc/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /doc/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /doc/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /doc/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /doc/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /doc/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /doc/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /doc/js/MathJax-config/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/js/MathJax-config/.gitignore -------------------------------------------------------------------------------- /doc/js/ie10-viewport-bug-workaround.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * IE10 viewport hack for Surface/desktop Windows 8 bug 3 | * Copyright 2014 Twitter, Inc. 4 | * Licensed under the Creative Commons Attribution 3.0 Unported License. For 5 | * details, see http://creativecommons.org/licenses/by/3.0/. 6 | */ 7 | 8 | // See the Getting Started docs for more information: 9 | // http://getbootstrap.com/getting-started/#support-ie10-width 10 | 11 | (function () { 12 | 'use strict'; 13 | if (navigator.userAgent.match(/IEMobile\/10\.0/)) { 14 | var msViewportStyle = document.createElement('style') 15 | msViewportStyle.appendChild( 16 | document.createTextNode( 17 | '@-ms-viewport{width:auto!important}' 18 | ) 19 | ) 20 | document.querySelector('head').appendChild(msViewportStyle) 21 | } 22 | })(); 23 | -------------------------------------------------------------------------------- /doc/search.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Search Results – FPLOT 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 85 | 86 |
87 |
88 |
89 |

Search Results

90 |
91 |
92 |
93 | 105 | 110 |
111 |
112 |
113 |
114 |
115 |

FPLOT was developed by Jason Christopherson
© 2025 116 |

117 |
118 |
119 |

120 | Documentation generated by 121 | FORD 122 | on 2025-04-10 13:38

123 |
124 |
125 |
126 |
127 |
128 | 129 | 131 | 132 | 135 | 136 | 137 | 138 | 139 | 141 | 142 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /doc/src/fplot_colors.f90: -------------------------------------------------------------------------------- 1 | ! fplot_colors.f90 2 | 3 | module fplot_colors 4 | use iso_fortran_env 5 | implicit none 6 | private 7 | public :: color 8 | public :: operator(==) 9 | public :: operator(/=) 10 | public :: CLR_BLACK 11 | public :: CLR_WHITE 12 | public :: CLR_RED 13 | public :: CLR_LIME 14 | public :: CLR_BLUE 15 | public :: CLR_YELLOW 16 | public :: CLR_CYAN 17 | public :: CLR_MAGENTA 18 | public :: CLR_SILVER 19 | public :: CLR_GRAY 20 | public :: CLR_MAROON 21 | public :: CLR_OLIVE 22 | public :: CLR_GREEN 23 | public :: CLR_PURPLE 24 | public :: CLR_TEAL 25 | public :: CLR_NAVY 26 | public :: CLR_ORANGE 27 | public :: color_list 28 | 29 | type color 30 | !! Describes an RGB color. 31 | integer(int32), public :: red = 0 32 | !! The red component of the color (must be between 0 and 255). 33 | integer(int32), public :: green = 0 34 | !! The green component of the color (must be between 0 and 255). 35 | integer(int32), public :: blue = 255 36 | !! The blue component of the color (must be between 0 and 255). 37 | integer(int32), public :: alpha = 0 38 | !! The alpha component of the color (must be between 0 and 255). 39 | !! Notice, 0 is fully opaque and 255 is fully transparent. 40 | contains 41 | procedure, public, pass :: to_hex_string => clr_to_hex_string 42 | procedure, public, pass :: copy_from => clr_copy_from 43 | end type 44 | 45 | interface operator(==) 46 | module procedure :: clr_equals 47 | end interface 48 | 49 | interface operator(/=) 50 | module procedure :: clr_not_equals 51 | end interface 52 | 53 | type(color), parameter :: CLR_BLACK = color(0, 0, 0, 0) 54 | !! Black. 55 | type(color), parameter :: CLR_WHITE = color(255, 255, 255, 0) 56 | !! White. 57 | type(color), parameter :: CLR_RED = color(255, 0, 0, 0) 58 | !! Red. 59 | type(color), parameter :: CLR_LIME = color(0, 255, 0, 0) 60 | !! Lime. 61 | type(color), parameter :: CLR_BLUE = color(0, 0, 255, 0) 62 | !! Blue. 63 | type(color), parameter :: CLR_YELLOW = color(255, 255, 0, 0) 64 | !! Yellow. 65 | type(color), parameter :: CLR_CYAN = color(0, 255, 255, 0) 66 | !! Cyan. 67 | type(color), parameter :: CLR_MAGENTA = color(255, 0, 255, 0) 68 | !! Magenta. 69 | type(color), parameter :: CLR_SILVER = color(192, 192, 192, 0) 70 | !! Silver. 71 | type(color), parameter :: CLR_GRAY = color(128, 128, 128, 0) 72 | !! Gray. 73 | type(color), parameter :: CLR_MAROON = color(128, 0, 0, 0) 74 | !! Maroon. 75 | type(color), parameter :: CLR_OLIVE = color(128, 128, 0, 0) 76 | !! Olive. 77 | type(color), parameter :: CLR_GREEN = color(0, 128, 0, 0) 78 | !! Green. 79 | type(color), parameter :: CLR_PURPLE = color(128, 0, 128, 0) 80 | !! Purple. 81 | type(color), parameter :: CLR_TEAL = color(0, 128, 128, 0) 82 | !! Teal. 83 | type(color), parameter :: CLR_NAVY = color(0, 0, 128, 0) 84 | !! Navy. 85 | type(color), parameter :: CLR_ORANGE = color(255, 165, 0, 0) 86 | !! Orange. 87 | 88 | ! A list of colors that can be cycled through by plotting code 89 | type(color), parameter, dimension(7) :: color_list = [ & 90 | color(0, int(0.447 * 255), int(0.741 * 255), 0), & 91 | color(int(0.85 * 255), int(0.325 * 255), int(0.098 * 255), 0), & 92 | color(int(0.929 * 255), int(0.694 * 255), int(0.125 * 255), 0), & 93 | color(int(0.494 * 255), int(0.184 * 255), int(0.556 * 255), 0), & 94 | color(int(0.466 * 255), int(0.674 * 255), int(0.188 * 255), 0), & 95 | color(int(0.301 * 255), int(0.745 * 255), int(0.933 * 255), 0), & 96 | color(int(0.635 * 255), int(0.078 * 255), int(0.184 * 255), 0)] 97 | 98 | contains 99 | ! ------------------------------------------------------------------------------ 100 | pure function clr_to_hex_string(this) result(txt) 101 | !! Returns the color in hexadecimal format. 102 | class(color), intent(in) :: this 103 | !! The color object. 104 | character(8) :: txt 105 | !! A string containing the hexadecimal equivalent. 106 | 107 | ! Local Variables 108 | integer(int32) :: r, g, b, a, clr 109 | 110 | ! Clip each color if necessary 111 | if (this%red < 0) then 112 | r = 0 113 | else if (this%red > 255) then 114 | r = 255 115 | else 116 | r = this%red 117 | end if 118 | 119 | if (this%green < 0) then 120 | g = 0 121 | else if (this%green > 255) then 122 | g = 255 123 | else 124 | g = this%green 125 | end if 126 | 127 | if (this%blue < 0) then 128 | b = 0 129 | else if (this%blue > 255) then 130 | b = 255 131 | else 132 | b = this%blue 133 | end if 134 | 135 | if (this%alpha < 0) then 136 | a = 0 137 | else if (this%alpha > 255) then 138 | a = 255 139 | else 140 | a = this%alpha 141 | end if 142 | 143 | ! Build the color information 144 | clr = ishft(a, 24) + ishft(r, 16) + ishft(g, 8) + b 145 | 146 | ! Convert the integer to a hexadecimal string 147 | write(txt, '(Z8.8)') clr 148 | end function 149 | 150 | ! ------------------------------------------------------------------------------ 151 | subroutine clr_copy_from(this, clr) 152 | !! Copies another color to this color. 153 | class(color), intent(inout) :: this 154 | !! The color object. 155 | class(color), intent(in) :: clr 156 | !! The color to copy. 157 | 158 | this%red = clr%red 159 | this%green = clr%green 160 | this%blue = clr%blue 161 | end subroutine 162 | 163 | ! ****************************************************************************** 164 | ! ADDED: JAN. 09, 2024 - JAC 165 | ! ------------------------------------------------------------------------------ 166 | ! pure subroutine clr_assign(x, y) 167 | ! type(color), intent(out) :: x 168 | ! class(color), intent(in) :: y 169 | ! call x%copy_from(y) 170 | ! end subroutine 171 | 172 | ! ------------------------------------------------------------------------------ 173 | pure function clr_equals(x, y) result(rst) 174 | type(color), intent(in) :: x, y 175 | logical :: rst 176 | rst = .true. 177 | if (x%red /= y%red .or. & 178 | x%green /= y%green .or. & 179 | x%blue /= y%blue & 180 | ) then 181 | rst = .false. 182 | end if 183 | end function 184 | 185 | ! ------------------------------------------------------------------------------ 186 | pure function clr_not_equals(x, y) result(rst) 187 | type(color), intent(in) :: x, y 188 | logical :: rst 189 | rst = .not.clr_equals(x, y) 190 | end function 191 | 192 | ! ------------------------------------------------------------------------------ 193 | end module -------------------------------------------------------------------------------- /doc/src/fplot_core_routines.f90: -------------------------------------------------------------------------------- 1 | ! fplot_core_routines.f90 2 | 3 | module fplot_core_routines 4 | use iso_fortran_env 5 | implicit none 6 | private 7 | public :: linspace 8 | public :: logspace 9 | public :: meshgrid 10 | 11 | contains 12 | ! ------------------------------------------------------------------------------ 13 | pure function linspace(start, finish, npts) result(x) 14 | !! Constructs a linearly spaced array. 15 | real(real64), intent(in) :: start 16 | !! The first value in the array. 17 | real(real64), intent(in) :: finish 18 | !! The last value in the array. 19 | integer(int32), intent(in) :: npts 20 | !! The number of values in the array. 21 | real(real64), allocatable, dimension(:) :: x 22 | !! The resulting array. 23 | 24 | ! Local Variables 25 | integer(int32) :: i 26 | real(real64) :: dx 27 | 28 | ! Process 29 | allocate(x(npts)) 30 | dx = (finish - start) / (npts - 1.0d0) 31 | x(1) = start 32 | do i = 2, npts 33 | x(i) = x(i-1) + dx 34 | end do 35 | end function 36 | 37 | ! ------------------------------------------------------------------------------ 38 | pure function logspace(start, finish, npts) result(x) 39 | !! Construcst a logarithmically spaced array. 40 | real(real64), intent(in) :: start 41 | !! The exponent of the first value in the array. 42 | real(real64), intent(in) :: finish 43 | !! The exponent of the final value in the array. 44 | integer(int32), intent(in) :: npts 45 | !! The number of values in the array. 46 | real(real64), allocatable, dimension(:) :: x 47 | !! The resulting array. 48 | 49 | ! Local Variables 50 | integer(int32) :: i 51 | real(real64) :: dx, exponent 52 | 53 | ! Process 54 | allocate(x(npts)) 55 | dx = (finish - start) / (npts - 1.0d0) 56 | exponent = start 57 | do i = 1, npts 58 | x(i) = 1.0d1**exponent 59 | exponent = exponent + dx 60 | end do 61 | end function 62 | 63 | ! ------------------------------------------------------------------------------ 64 | pure function meshgrid(x, y) result(xy) 65 | !! Constructs two matrices (X and Y) from x and y data arrays. 66 | real(real64), intent(in), dimension(:) :: x 67 | !! An M-element array of x data points. 68 | real(real64), intent(in), dimension(:) :: y 69 | !! An N-element array of y data points. 70 | real(real64), allocatable, dimension(:,:,:) :: xy 71 | !! An N-by-M-by-2 array containing the x data matrix on the first 72 | !! page of the array, and the y data matrix on the second page. 73 | 74 | ! Local Variables 75 | integer(int32) :: i, nx, ny 76 | 77 | ! Process 78 | nx = size(x) 79 | ny = size(y) 80 | allocate(xy(ny, nx, 2)) 81 | do i = 1, ny 82 | xy(i,:,1) = x 83 | end do 84 | do i = 1, nx 85 | xy(:,i,2) = y 86 | end do 87 | end function 88 | 89 | end module 90 | -------------------------------------------------------------------------------- /doc/src/fplot_errors.f90: -------------------------------------------------------------------------------- 1 | module fplot_errors 2 | use iso_fortran_env 3 | use ferror 4 | implicit none 5 | 6 | ! ****************************************************************************** 7 | ! ERROR CODES 8 | ! ------------------------------------------------------------------------------ 9 | integer(int32), parameter :: PLOT_OUT_OF_MEMORY_ERROR = 1000 10 | !! Occurs if there is insufficient memory available for the 11 | !! requested operation. 12 | integer(int32), parameter :: PLOT_INVALID_INPUT_ERROR = 1001 13 | !! Occurs if an invalid input is provided. 14 | integer(int32), parameter :: PLOT_INVALID_OPERATION_ERROR = 1002 15 | !! Occurs if an attempt is made to perform an invalid operation. 16 | integer(int32), parameter :: PLOT_ARRAY_SIZE_MISMATCH_ERROR = 1003 17 | !! Occurs if there is an array size mismatch error. 18 | integer(int32), parameter :: PLOT_GNUPLOT_FILE_ERROR = 1004 19 | !! Occurs if there is a GNUPLOT file error. 20 | 21 | contains 22 | ! ------------------------------------------------------------------------------ 23 | subroutine report_memory_error(err, fcn, flag) 24 | !! Reports a memory allocation error. 25 | class(errors), intent(inout) :: err 26 | !! The error handling object. 27 | character(len = *), intent(in) :: fcn 28 | !! The name of the function or subroutine in which the error occurred. 29 | integer(int32), intent(in) :: flag 30 | !! The error flag returned by the system. 31 | 32 | ! Local Variables 33 | character(len = 256) :: msg 34 | 35 | ! Define the error message 36 | write(100, msg) "Memory allocation error returning flag ", flag, "." 37 | call err%report_error(fcn, trim(msg), PLOT_OUT_OF_MEMORY_ERROR) 38 | 39 | ! Formatting 40 | 100 format(A, I0, A) 41 | end subroutine 42 | 43 | ! ------------------------------------------------------------------------------ 44 | subroutine report_file_create_error(err, fcn, fname, flag) 45 | !! Reports an I/O error related to file creating. 46 | class(errors), intent(inout) :: err 47 | !! The error handling object. 48 | character(len = *), intent(in) :: fcn 49 | !! The name of the function or subroutine in which the error occurred. 50 | character(len = *), intent(in) :: fname 51 | !! The filename. 52 | integer(int32), intent(in) :: flag 53 | !! The error flag returned by the system. 54 | 55 | ! Local Variables 56 | character(len = 2048) :: msg 57 | 58 | ! Define the error message 59 | write(100, msg) "File ", fname, " could not be created. The error flag ", & 60 | flag, " was returned." 61 | call err%report_error(fcn, trim(msg), PLOT_GNUPLOT_FILE_ERROR) 62 | 63 | ! Formatting 64 | 100 format(A, A, A, I0, A) 65 | end subroutine 66 | 67 | ! ------------------------------------------------------------------------------ 68 | subroutine report_array_size_mismatch_error(err, fcn, name, expected, actual) 69 | !! Reports an array size mismatch error. 70 | class(errors), intent(inout) :: err 71 | !! The error handling object. 72 | character(len = *), intent(in) :: fcn 73 | !! The name of the function or subroutine in which the error occurred. 74 | character(len = *), intent(in) :: name 75 | !! The variable name. 76 | integer(int32), intent(in) :: expected 77 | !! The expected array size. 78 | integer(int32), intent(in) :: actual 79 | !! The actual array size. 80 | 81 | ! Local Variables 82 | character(len = 256) :: msg 83 | 84 | ! Define the message 85 | write(100, msg) "Array ", name, " was found to be of length ", actual, & 86 | ", but was expected to be of length ", expected, "." 87 | call err%report_error(fcn, trim(msg), PLOT_ARRAY_SIZE_MISMATCH_ERROR) 88 | 89 | ! Formatting 90 | 100 format(A, A, A, I0, A, I0, A) 91 | end subroutine 92 | 93 | ! ------------------------------------------------------------------------------ 94 | subroutine report_matrix_size_mismatch_error(err, fcn, name, mexp, nexp, & 95 | mact, nact) 96 | !! Reports a matrix size mismatch error. 97 | class(errors), intent(inout) :: err 98 | !! The error handling object. 99 | character(len = *), intent(in) :: fcn 100 | !! The name of the function or subroutine in which the error occurred. 101 | character(len = *), intent(in) :: name 102 | !! The variable name. 103 | integer(int32), intent(in) :: mexp 104 | !! The expected number of rows. 105 | integer(int32), intent(in) :: nexp 106 | !! The expected number of columns. 107 | integer(int32), intent(in) :: mact 108 | !! The actual number of rows. 109 | integer(int32), intent(in) :: nact 110 | !! The actual number of columns. 111 | 112 | ! Local Variables 113 | character(len = 256) :: msg 114 | 115 | ! Define the error 116 | write(100, msg) "Matrix ", name, " was expected to be of size ", mexp, & 117 | "-by-", nexp, ", but was found to be of size ", mact, "-by-", nact, "." 118 | call err%report_error(fcn, trim(msg), PLOT_ARRAY_SIZE_MISMATCH_ERROR) 119 | 120 | ! Formatting 121 | 100 format(A, A, A, I0, A, I0, A, I0, A, I0, A) 122 | end subroutine 123 | 124 | ! ------------------------------------------------------------------------------ 125 | end module -------------------------------------------------------------------------------- /doc/src/fplot_label.f90: -------------------------------------------------------------------------------- 1 | ! fplot_label.f90 2 | 3 | module fplot_label 4 | use iso_fortran_env 5 | use fplot_plot_object 6 | use fplot_constants 7 | use strings 8 | implicit none 9 | private 10 | public :: plot_label 11 | 12 | type, extends(plot_object) :: plot_label 13 | !! Defines a plot label. 14 | logical, private :: m_visible = .true. 15 | !! Is the label visible? 16 | real(real32), private, dimension(3) :: m_position 17 | !! The x, y, and z coordinates of the label. 18 | real(real32), private :: m_angle = 0.0 19 | !! The rotation angle of the label. 20 | character(len = PLOTDATA_MAX_NAME_LENGTH), private :: m_text 21 | !! The label text. 22 | contains 23 | procedure, public :: get_command_string => lbl_get_cmd 24 | procedure, public :: get_is_visible => lbl_get_is_visible 25 | procedure, public :: set_is_visible => lbl_set_is_visible 26 | procedure, public :: get_position => lbl_get_position 27 | procedure, public :: set_position => lbl_set_position 28 | procedure, public :: get_angle => lbl_get_angle 29 | procedure, public :: set_angle => lbl_set_angle 30 | procedure, public :: get_text => lbl_get_txt 31 | procedure, public :: set_text => lbl_set_txt 32 | end type 33 | contains 34 | ! ------------------------------------------------------------------------------ 35 | function lbl_get_cmd(this) result(x) 36 | !! Gets the GNUPLOT command string for the label. 37 | class(plot_label), intent(in) :: this 38 | !! The plot_label object. 39 | character(len = :), allocatable :: x 40 | !! The command string. 41 | 42 | ! Local Variables 43 | type(string_builder) :: str 44 | real(real32) :: pt(3) 45 | 46 | ! Initialization 47 | call str%initialize() 48 | pt = this%get_position() 49 | 50 | ! If visible, draw the label 51 | if (this%get_is_visible()) then 52 | call str%append('set label "') 53 | call str%append(this%get_text()) 54 | call str%append('"') 55 | 56 | call str%append(" at ") 57 | call str%append(to_string(pt(1))) 58 | call str%append(",") 59 | call str%append(to_string(pt(2))) 60 | call str%append(",") 61 | call str%append(to_string(pt(3))) 62 | 63 | call str%append(" rotate by ") 64 | call str%append(to_string(this%get_angle())) 65 | 66 | x = char(str%to_string()) 67 | end if 68 | end function 69 | 70 | ! ------------------------------------------------------------------------------ 71 | pure function lbl_get_is_visible(this) result(x) 72 | !! Gets a value determining if the label is to be drawn. 73 | class(plot_label), intent(in) :: this 74 | !! The plot_label object. 75 | logical :: x 76 | !! Returns true if the label is to be drawn; else, false. 77 | x = this%m_visible 78 | end function 79 | 80 | ! -------------------- 81 | subroutine lbl_set_is_visible(this, x) 82 | !! Sets a value determining if the label is to be drawn. 83 | class(plot_label), intent(inout) :: this 84 | !! The plot_label object. 85 | logical, intent(in) :: x 86 | !! Set to true if the label is to be drawn; else, false. 87 | this%m_visible = x 88 | end subroutine 89 | 90 | ! ------------------------------------------------------------------------------ 91 | pure function lbl_get_position(this) result(x) 92 | !! Gets the position of the label in terms of plot coordinates. 93 | class(plot_label), intent(in) :: this 94 | !! The plot_label object. 95 | real(real32), dimension(3) :: x 96 | !! A 3-element array containing the X, Y, and Z position of the 97 | !! label. 98 | x = this%m_position 99 | end function 100 | 101 | ! -------------------- 102 | subroutine lbl_set_position(this, x) 103 | !! Sets the position of the label in terms of plot coordinates. 104 | class(plot_label), intent(inout) :: this 105 | !! The plot_label object. 106 | real(real32), intent(in), dimension(3) :: x 107 | !! A 3-element array containing the X, Y, and Z position of the 108 | !! label. 109 | this%m_position = x 110 | end subroutine 111 | 112 | ! ------------------------------------------------------------------------------ 113 | pure function lbl_get_angle(this) result(x) 114 | !! Gets the angle of the label text, in degrees. 115 | class(plot_label), intent(in) :: this 116 | !! The plot_label object. 117 | real(real32) :: x 118 | !! The angle, in degrees. 119 | x = this%m_angle 120 | end function 121 | 122 | ! -------------------- 123 | subroutine lbl_set_angle(this, x) 124 | !! Sets the angle of the label text, in degrees. 125 | class(plot_label), intent(inout) :: this 126 | !! The plot_label object. 127 | real(real32), intent(in) :: x 128 | !! The angle, in degrees. 129 | this%m_angle = x 130 | end subroutine 131 | 132 | ! ------------------------------------------------------------------------------ 133 | function lbl_get_txt(this) result(x) 134 | !! Gets the text displayed by the label. 135 | class(plot_label), intent(in) :: this 136 | !! The plot_label object. 137 | character(len = :), allocatable :: x 138 | !! The text string to display. 139 | x = trim(this%m_text) 140 | end function 141 | 142 | ! -------------------- 143 | subroutine lbl_set_txt(this, x) 144 | !! Sets the text displayed by the label. 145 | class(plot_label), intent(inout) :: this 146 | !! The plot_label object. 147 | character(len = *), intent(in) :: x 148 | !! The text string to display. 149 | integer(int32) :: n 150 | n = min(len(x), PLOTDATA_MAX_NAME_LENGTH) 151 | this%m_text = "" 152 | this%m_text(1:n) = x(1:n) 153 | end subroutine 154 | 155 | ! ****************************************************************************** 156 | ! ADDED: JAN. 09, 2024 - JAC 157 | ! ------------------------------------------------------------------------------ 158 | ! pure subroutine lbl_assign(x, y) 159 | ! type(plot_label), intent(out) :: x 160 | ! class(plot_label), intent(in) :: y 161 | ! x%m_visible = y%m_visible 162 | ! x%m_position = y%m_position 163 | ! x%m_angle = y%m_angle 164 | ! x%m_text = y%m_text 165 | ! end subroutine 166 | 167 | ! ------------------------------------------------------------------------------ 168 | end module 169 | -------------------------------------------------------------------------------- /doc/src/fplot_latex_terminal.f90: -------------------------------------------------------------------------------- 1 | ! fplot_latex_terminal.f90 2 | 3 | module fplot_latex_terminal 4 | use iso_fortran_env 5 | use fplot_terminal 6 | use fplot_constants 7 | use strings 8 | implicit none 9 | private 10 | public :: latex_terminal 11 | 12 | type, extends(terminal) :: latex_terminal 13 | !! A LATEX terminal. 14 | character(len = 14), private :: m_id = "epslatex color" 15 | !! The terminal ID string 16 | character(len = GNUPLOT_MAX_PATH_LENGTH), private :: m_fname = "default.tex" 17 | !! The filename of the file to write. 18 | contains 19 | procedure, public :: get_filename => tex_get_filename 20 | procedure, public :: set_filename => tex_set_filename 21 | procedure, public :: get_id_string => tex_get_term_string 22 | procedure, public :: get_command_string => tex_get_command_string 23 | end type 24 | 25 | contains 26 | ! ------------------------------------------------------------------------------ 27 | function tex_get_term_string(this) result(x) 28 | !! Retrieves a GNUPLOT terminal identifier string. 29 | class(latex_terminal), intent(in) :: this 30 | !! The latex_terminal object. 31 | character(len = :), allocatable :: x 32 | !! The string. 33 | integer(int32) :: n 34 | n = len_trim(this%m_id) 35 | allocate(character(len = n) :: x) 36 | x = this%m_id 37 | end function 38 | 39 | ! ------------------------------------------------------------------------------ 40 | function tex_get_filename(this) result(txt) 41 | !! Gets the filename for the output LATEX file. 42 | class(latex_terminal), intent(in) :: this 43 | !! The latex_terminal object. 44 | character(len = :), allocatable :: txt 45 | !! The filename, including the file extension (.tex). 46 | integer(int32) :: n 47 | n = len_trim(this%m_fname) 48 | allocate(character(len = n) :: txt) 49 | txt = trim(this%m_fname) 50 | end function 51 | 52 | ! -------------------- 53 | subroutine tex_set_filename(this, txt) 54 | !! Sets the filename for the output LATEX file. 55 | class(latex_terminal), intent(inout) :: this 56 | !! The latex_terminal object. 57 | character(len = *), intent(in) :: txt 58 | !! The filename, including the file extension (.tex). 59 | integer(int32) :: n 60 | n = min(len_trim(txt), GNUPLOT_MAX_PATH_LENGTH) 61 | this%m_fname = "" 62 | if (n /= 0) then 63 | this%m_fname(1:n) = txt(1:n) 64 | else 65 | this%m_fname = "default.tex" 66 | end if 67 | end subroutine 68 | 69 | ! ------------------------------------------------------------------------------ 70 | function tex_get_command_string(this) result(x) 71 | !! Returns the appropriate GNUPLOT command string to establish 72 | !! appropriate parameters. 73 | class(latex_terminal), intent(in) :: this 74 | !! The latex_terminal object. 75 | character(len = :), allocatable :: x 76 | !! The GNUPLOT command string. 77 | 78 | ! Local Variables 79 | type(string_builder) :: str 80 | 81 | ! Process 82 | call str%initialize() 83 | call str%append("set term epslatex color ") 84 | call str%append(" font ") 85 | call str%append('"') 86 | call str%append(this%get_font_name()) 87 | call str%append(',') 88 | call str%append(to_string(this%get_font_size())) 89 | call str%append('"') 90 | call str%append(" size ") 91 | call str%append(to_string(this%get_window_width())) 92 | call str%append(",") 93 | call str%append(to_string(this%get_window_height())) 94 | call str%append(new_line('a')) 95 | call str%append("set output ") 96 | call str%append('"') 97 | call str%append(this%get_filename()) 98 | call str%append('"') 99 | x = char(str%to_string()) 100 | end function 101 | 102 | end module 103 | -------------------------------------------------------------------------------- /doc/src/fplot_plot_bar.f90: -------------------------------------------------------------------------------- 1 | ! fplot_plot_bar.f90 2 | 3 | module fplot_plot_bar 4 | use iso_fortran_env 5 | use fplot_plot_2d 6 | use strings 7 | implicit none 8 | private 9 | public :: plot_bar 10 | 11 | type, extends(plot_2d) :: plot_bar 12 | !! Defines a 2D plot tailored towards bar plotting. 13 | real(real32), private :: m_barWidth = 1.0d0 14 | !! A relative scaling of the width of a single bar. The value 15 | !! must be between 0 and 1 with 1 being full width. 16 | contains 17 | procedure, public :: get_bar_width => pb_get_bar_width 18 | procedure, public :: set_bar_width => pb_set_bar_width 19 | procedure, public :: get_command_string => pb_get_cmd 20 | end type 21 | 22 | contains 23 | ! ------------------------------------------------------------------------------ 24 | pure function pb_get_bar_width(this) result(x) 25 | !! Gets the bar width scaling factor. 26 | class(plot_bar), intent(in) :: this 27 | !! The plot_bar object. 28 | real(real32) :: x 29 | !! The scaling factor. 30 | x = this%m_barWidth 31 | end function 32 | 33 | ! ------------------------------------------------------------------------------ 34 | subroutine pb_set_bar_width(this, x) 35 | !! Sets the bar width scaling factor. 36 | class(plot_bar), intent(inout) :: this 37 | !! The plot_bar object. 38 | real(real32), intent(in) :: x 39 | !! The scaling factor. The value must be in the set [0, 1]; else, the 40 | !! value will be shifted accordingly. 41 | if (x > 1.0) then 42 | this%m_barWidth = 1.0 43 | else if (x < 0.0) then 44 | this%m_barWidth = 0.0 45 | else 46 | this%m_barWidth = x 47 | end if 48 | end subroutine 49 | 50 | ! ------------------------------------------------------------------------------ 51 | function pb_get_cmd(this) result(x) 52 | !! Gets the GNUPLOT commands required to draw the plot. 53 | class(plot_bar), intent(in) :: this 54 | !! The plot_bar object. 55 | character(len = :), allocatable :: x 56 | !! The command string. 57 | 58 | ! Local Variables 59 | type(string_builder) :: str 60 | 61 | ! Initialization 62 | call str%initialize() 63 | 64 | ! Box Width 65 | call str%append(new_line('a')) 66 | call str%append("set boxwidth ") 67 | call str%append(to_string(this%get_bar_width())) 68 | call str%append(" relative") 69 | 70 | ! Call the base routine to establish the remainder of the plot 71 | call str%append(this%plot_2d%get_command_string()) 72 | 73 | ! End 74 | x = char(str%to_string()) 75 | end function 76 | 77 | ! ------------------------------------------------------------------------------ 78 | ! TO DO YET: 79 | ! - clustering 80 | ! - stacking 81 | ! - lighting 82 | end module 83 | -------------------------------------------------------------------------------- /doc/src/fplot_plot_object.f90: -------------------------------------------------------------------------------- 1 | module fplot_plot_object 2 | use iso_fortran_env 3 | implicit none 4 | 5 | type, abstract :: plot_object 6 | !! The base type for all plot objects. 7 | contains 8 | procedure(get_string_result), deferred, public :: get_command_string 9 | end type 10 | 11 | interface 12 | function get_string_result(this) result(x) 13 | !! Returns a string from a plot_object. 14 | import plot_object 15 | class(plot_object), intent(in) :: this 16 | !! The plot_object object. 17 | character(len = :), allocatable :: x 18 | !! The result string. 19 | end function 20 | end interface 21 | end module -------------------------------------------------------------------------------- /doc/src/fplot_png_terminal.f90: -------------------------------------------------------------------------------- 1 | ! fplot_png_terminal.f90 2 | 3 | module fplot_png_terminal 4 | use iso_fortran_env 5 | use strings 6 | use fplot_terminal 7 | use fplot_constants 8 | implicit none 9 | private 10 | public :: png_terminal 11 | 12 | type, extends(terminal) :: png_terminal 13 | !! Defines a terminal used for producing PNG outputs. 14 | character(len = 3), private :: m_id = "png" 15 | !! The terminal ID string 16 | character(len = GNUPLOT_MAX_PATH_LENGTH), private :: m_fname = "default.png" 17 | !! The filename of the PNG file to write. 18 | contains 19 | procedure, public :: get_filename => png_get_filename 20 | procedure, public :: set_filename => png_set_filename 21 | procedure, public :: get_id_string => png_get_term_string 22 | procedure, public :: get_command_string => png_get_command_string 23 | end type 24 | 25 | contains 26 | ! ------------------------------------------------------------------------------ 27 | function png_get_term_string(this) result(x) 28 | !! Retrieves a GNUPLOT terminal identifier string. 29 | class(png_terminal), intent(in) :: this 30 | !! The png_terminal object. 31 | character(len = :), allocatable :: x 32 | !! The string. 33 | integer(int32) :: n 34 | n = len_trim(this%m_id) 35 | allocate(character(len = n) :: x) 36 | x = this%m_id 37 | end function 38 | 39 | ! ------------------------------------------------------------------------------ 40 | function png_get_filename(this) result(txt) 41 | !! Gets the filename for the output PNG file. 42 | class(png_terminal), intent(in) :: this 43 | !! The png_terminal object. 44 | character(len = :), allocatable :: txt 45 | !! The filename, including the file extension (.png). 46 | integer(int32) :: n 47 | n = len_trim(this%m_fname) 48 | allocate(character(len = n) :: txt) 49 | txt = trim(this%m_fname) 50 | end function 51 | 52 | ! -------------------- 53 | subroutine png_set_filename(this, txt) 54 | !!Sets the filename for the output PNG file. 55 | class(png_terminal), intent(inout) :: this 56 | !! The png_terminal object. 57 | character(len = *), intent(in) :: txt 58 | !! The filename, including the file extension (.png). 59 | integer(int32) :: n 60 | n = min(len_trim(txt), GNUPLOT_MAX_PATH_LENGTH) 61 | this%m_fname = "" 62 | if (n /= 0) then 63 | this%m_fname(1:n) = txt(1:n) 64 | else 65 | this%m_fname = "default.png" 66 | end if 67 | end subroutine 68 | 69 | ! ------------------------------------------------------------------------------ 70 | function png_get_command_string(this) result(x) 71 | !! Returns the appropriate GNUPLOT command string to establish 72 | !! appropriate parameters. 73 | class(png_terminal), intent(in) :: this 74 | !! The png_terminal object. 75 | character(len = :), allocatable :: x 76 | !! The GNUPLOT command string. 77 | 78 | ! Local Variables 79 | type(string_builder) :: str 80 | 81 | ! Process 82 | call str%initialize() 83 | call str%append("set term pngcairo enhanced ") 84 | call str%append(" font ") 85 | call str%append('"') 86 | call str%append(this%get_font_name()) 87 | call str%append(',') 88 | call str%append(to_string(this%get_font_size())) 89 | call str%append('"') 90 | call str%append(" size ") 91 | call str%append(to_string(this%get_window_width())) 92 | call str%append(",") 93 | call str%append(to_string(this%get_window_height())) 94 | call str%append(new_line('a')) 95 | call str%append("set output ") 96 | call str%append('"') 97 | call str%append(this%get_filename()) 98 | call str%append('"') 99 | x = char(str%to_string()) 100 | end function 101 | 102 | end module -------------------------------------------------------------------------------- /doc/src/fplot_qt_terminal.f90: -------------------------------------------------------------------------------- 1 | ! fplot_qt_terminal.f90 2 | 3 | module fplot_qt_terminal 4 | use iso_fortran_env 5 | use fplot_terminal 6 | implicit none 7 | private 8 | public :: qt_terminal 9 | 10 | type, extends(terminal) :: qt_terminal 11 | !! Defines a terminal that utilizes QT. 12 | character(len = 2), private :: m_id = "qt" 13 | !! The terminal ID string 14 | contains 15 | procedure, public :: get_id_string => qt_get_term_string 16 | end type 17 | 18 | contains 19 | function qt_get_term_string(this) result(x) 20 | !! Retrieves a GNUPLOT terminal identifier string. 21 | class(qt_terminal), intent(in) :: this 22 | !! The qt_terminal object. 23 | character(len = :), allocatable :: x 24 | !! The string. 25 | integer(int32) :: n 26 | n = len_trim(this%m_id) 27 | allocate(character(len = n) :: x) 28 | x = this%m_id 29 | end function 30 | end module 31 | -------------------------------------------------------------------------------- /doc/src/fplot_windows_terminal.f90: -------------------------------------------------------------------------------- 1 | ! fplot_windows_terminal.f90 2 | 3 | module fplot_windows_terminal 4 | use iso_fortran_env 5 | use fplot_terminal 6 | implicit none 7 | private 8 | public :: windows_terminal 9 | 10 | type, extends(terminal) :: windows_terminal 11 | !! A Windows-specific terminal. 12 | character(len = 3), private :: m_id = "win" 13 | !! The terminal ID string 14 | contains 15 | procedure, public :: get_id_string => wt_get_term_string 16 | end type 17 | 18 | contains 19 | 20 | function wt_get_term_string(this) result(x) 21 | !! Retrieves a GNUPLOT terminal identifier string. 22 | class(windows_terminal), intent(in) :: this 23 | !! The windows_terminal object. 24 | character(len = :), allocatable :: x 25 | !! The string. 26 | integer(int32) :: n 27 | n = len_trim(this%m_id) 28 | allocate(character(len = n) :: x) 29 | x = this%m_id 30 | end function 31 | 32 | end module 33 | -------------------------------------------------------------------------------- /doc/src/fplot_wxt_terminal.f90: -------------------------------------------------------------------------------- 1 | ! fplot_wxt_terminal.f90 2 | 3 | module fplot_wxt_terminal 4 | use iso_fortran_env 5 | use fplot_terminal 6 | implicit none 7 | private 8 | public :: wxt_terminal 9 | 10 | type, extends(terminal) :: wxt_terminal 11 | !! A WXT terminal. 12 | character(len = 3), private :: m_id = "wxt" 13 | !! The terminal ID string 14 | contains 15 | procedure, public :: get_id_string => wxt_get_term_string 16 | end type 17 | 18 | contains 19 | function wxt_get_term_string(this) result(x) 20 | !! Retrieves a GNUPLOT terminal identifier string. 21 | class(wxt_terminal), intent(in) :: this 22 | !! The wxt_terminal object. 23 | character(len = :), allocatable :: x 24 | !! The string. 25 | integer(int32) :: n 26 | n = len_trim(this%m_id) 27 | allocate(character(len = n) :: x) 28 | x = this%m_id 29 | end function 30 | end module 31 | -------------------------------------------------------------------------------- /doc/tipuesearch/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/tipuesearch/.DS_Store -------------------------------------------------------------------------------- /doc/tipuesearch/img/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/tipuesearch/img/.DS_Store -------------------------------------------------------------------------------- /doc/tipuesearch/img/loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/tipuesearch/img/loader.gif -------------------------------------------------------------------------------- /doc/tipuesearch/img/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/doc/tipuesearch/img/search.png -------------------------------------------------------------------------------- /doc/tipuesearch/tipuesearch.css: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Tipue Search 4.0 4 | Copyright (c) 2014 Tipue 5 | Tipue Search is released under the MIT License 6 | http://www.tipue.com/search 7 | */ 8 | 9 | 10 | /* 11 | #tipue_search_input 12 | { 13 | font: 13px/1.6 'open sans', sans-serif; 14 | color: #333; 15 | padding: 12px 12px 12px 40px; 16 | width: 170px; 17 | border: 1px solid #e2e2e2; 18 | border-radius: 0; 19 | -moz-appearance: none; 20 | -webkit-appearance: none; 21 | box-shadow: none; 22 | outline: 0; 23 | margin: 0; 24 | background: #fff url('img/search.png') no-repeat 15px 15px; 25 | } 26 | */ 27 | 28 | #tipue_search_content 29 | { 30 | max-width: 650px; 31 | padding-top: 15px; 32 | margin: 0; 33 | } 34 | #tipue_search_loading 35 | { 36 | padding-top: 60px; 37 | background: #fff url('img/loader.gif') no-repeat left; 38 | } 39 | 40 | #tipue_search_warning_head 41 | { 42 | font: 300 15px/1.6 'Open Sans', sans-serif; 43 | color: #555; 44 | } 45 | #tipue_search_warning 46 | { 47 | font: 300 13px/1.6 'Open Sans', sans-serif; 48 | color: #333; 49 | margin: 7px 0; 50 | } 51 | #tipue_search_warning a 52 | { 53 | color: #36c; 54 | font-weight: 300; 55 | text-decoration: none; 56 | } 57 | #tipue_search_warning a:hover 58 | { 59 | color: #333; 60 | } 61 | #tipue_search_results_count 62 | { 63 | font: 300 13px/1.6 'Open Sans', sans-serif; 64 | color: #333; 65 | } 66 | .tipue_search_content_title 67 | { 68 | font: 300 25px/1.7 'Open Sans', sans-serif; 69 | text-rendering: optimizelegibility; 70 | margin-top: 23px; 71 | } 72 | .tipue_search_content_title a 73 | { 74 | color: #333; 75 | text-decoration: none; 76 | } 77 | .tipue_search_content_title a:hover 78 | { 79 | color: #555; 80 | } 81 | .tipue_search_content_url 82 | { 83 | font: 300 13px/1.7 'Open Sans', sans-serif; 84 | word-break: break-all; 85 | word-break: break-word; 86 | -webkit-hyphens: auto; 87 | -moz-hyphens: auto; 88 | hyphens: auto; 89 | } 90 | .tipue_search_content_url a 91 | { 92 | color: #06c; 93 | text-decoration: none; 94 | } 95 | .tipue_search_content_url a:hover 96 | { 97 | color: #333; 98 | } 99 | .tipue_search_content_text 100 | { 101 | font: 300 15px/1.6 'Open Sans', sans-serif; 102 | color: #555; 103 | word-break: break-all; 104 | word-break: break-word; 105 | -webkit-hyphens: auto; 106 | -moz-hyphens: auto; 107 | hyphens: auto; 108 | margin-top: 3px; 109 | } 110 | .h01 111 | { 112 | color: #333; 113 | font-weight: 400; 114 | } 115 | 116 | #tipue_search_foot 117 | { 118 | margin: 51px 0 21px 0; 119 | } 120 | #tipue_search_foot_boxes 121 | { 122 | padding: 0; 123 | margin: 0; 124 | font: 12px/1 'Open Sans', sans-serif; 125 | } 126 | #tipue_search_foot_boxes li 127 | { 128 | list-style: none; 129 | margin: 0; 130 | padding: 0; 131 | display: inline; 132 | } 133 | #tipue_search_foot_boxes li a 134 | { 135 | padding: 9px 15px 10px 15px; 136 | background-color: #f1f1f1; 137 | border: 1px solid #dcdcdc; 138 | border-radius: 1px; 139 | color: #333; 140 | margin-right: 7px; 141 | text-decoration: none; 142 | text-align: center; 143 | } 144 | #tipue_search_foot_boxes li.current 145 | { 146 | padding: 9px 15px 10px 15px; 147 | background: #fff; 148 | border: 1px solid #dcdcdc; 149 | border-radius: 1px; 150 | color: #333; 151 | margin-right: 7px; 152 | text-align: center; 153 | } 154 | #tipue_search_foot_boxes li a:hover 155 | { 156 | border: 1px solid #ccc; 157 | background-color: #f3f3f3; 158 | } 159 | -------------------------------------------------------------------------------- /doc/tipuesearch/tipuesearch.min.js: -------------------------------------------------------------------------------- 1 | (function($){$.fn.tipuesearch=function(options){var set=$.extend({"show":7,"newWindow":false,"showURL":true,"minimumLength":3,"descriptiveWords":25,"highlightTerms":true,"highlightEveryTerm":false,"mode":"static","liveDescription":"*","liveContent":"*","contentLocation":"tipuesearch/tipuesearch_content.json"},options);return this.each(function(){var tipuesearch_in={pages:[]};$.ajaxSetup({async:false});if(set.mode=="live")for(var i=0;i");var t_2=html.toLowerCase().indexOf("",t_1+7);if(t_1!=-1&&t_2!=-1)var tit=html.slice(t_1+7,t_2);else var tit="No title";tipuesearch_in.pages.push({"title":tit,"text":desc,"tags":cont,"loc":tipuesearch_pages[i]})});if(set.mode=="json")$.getJSON(set.contentLocation,function(json){tipuesearch_in=$.extend({},json)}); 3 | if(set.mode=="static")tipuesearch_in=$.extend({},tipuesearch);var tipue_search_w="";if(set.newWindow)tipue_search_w=' target="_blank"';function getURLP(name){return decodeURIComponent(((new RegExp("[?|&]"+name+"="+"([^&;]+?)(&|#|;|$)")).exec(location.search)||[,""])[1].replace(/\+/g,"%20"))||null}if(getURLP("q")){$("#tipue_search_input").val(getURLP("q"));getTipueSearch(0,true)}$(this).keyup(function(event){if(event.keyCode=="13")getTipueSearch(0,true)});function getTipueSearch(start,replace){$("#tipue_search_content").hide(); 4 | var out="";var results="";var show_replace=false;var show_stop=false;var standard=true;var c=0;found=new Array;var d=$("#tipue_search_input").val().toLowerCase();d=$.trim(d);if(d.match('^"')&&d.match('"$')||d.match("^'")&&d.match("'$"))standard=false;if(standard){var d_w=d.split(" ");d="";for(var i=0;i=set.minimumLength){if(standard){if(replace){var d_r=d;for(var i=0;i$1')}if(tipuesearch_in.pages[i].tags.search(pat)!= 7 | -1)score-=1E5-i;if(d_w[f].match("^-")){pat=new RegExp(d_w[f].substring(1),"i");if(tipuesearch_in.pages[i].title.search(pat)!=-1||tipuesearch_in.pages[i].text.search(pat)!=-1||tipuesearch_in.pages[i].tags.search(pat)!=-1)score=1E9}}if(score<1E9)found[c++]=score+"^"+tipuesearch_in.pages[i].title+"^"+s_t+"^"+tipuesearch_in.pages[i].loc}}else for(var i=0;i$1')}if(tipuesearch_in.pages[i].tags.search(pat)!=-1)score-=1E5-i;if(score<1E9)found[c++]=score+"^"+tipuesearch_in.pages[i].title+"^"+s_t+"^"+tipuesearch_in.pages[i].loc}if(c!=0){if(show_replace==1){out+='
Showing results for '+ 9 | d+"
";out+='
Search instead for '+d_r+"
"}if(c==1)out+='
1 result
';else{c_c=c.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");out+='
'+c_c+" results
"}found.sort();var l_o=0;for(var i=0;i=start&&l_o"+fo[1]+"";if(set.showURL)out+='";var t=fo[2];var t_d="";var t_w=t.split(" ");if(t_w.length"}l_o++}if(c>set.show){var pages=Math.ceil(c/set.show);var page=start/set.show; 11 | out+='
    ';if(start>0)out+='
  • Prev
  • ';if(page<=2){var p_b=pages;if(pages>3)p_b=3;for(var f=0;f'+(f+1)+"";else out+='
  • '+(f+1)+"
  • "}else{var p_b=page+2;if(p_b>pages)p_b=pages;for(var f=page- 12 | 1;f'+(f+1)+"";else out+='
  • '+(f+1)+"
  • "}if(page+1!=pages)out+='
  • Next
  • ';out+="
"}}else out+='
Nothing found
'}else if(show_stop)out+='
Nothing found
Common words are largely ignored
'; 13 | else{out+='
Search too short
';if(set.minimumLength==1)out+='
Should be one character or more
';else out+='
Should be '+set.minimumLength+" characters or more
"}$("#tipue_search_content").html(out);$("#tipue_search_content").slideDown(200);$("#tipue_search_replaced").click(function(){getTipueSearch(0,false)});$(".tipue_search_foot_box").click(function(){var id_v=$(this).attr("id");var id_a= 14 | id_v.split("_");getTipueSearch(parseInt(id_a[0]),id_a[1])})}})}})(jQuery); 15 | -------------------------------------------------------------------------------- /doc/tipuesearch/tipuesearch_set.js: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | Tipue Search 4.0 4 | Copyright (c) 2014 Tipue 5 | Tipue Search is released under the MIT License 6 | http://www.tipue.com/search 7 | */ 8 | 9 | 10 | var tipuesearch_stop_words = ["and", "be", "by", "do", "for", "he", "how", "if", "is", "it", "my", "not", "of", "or", "the", "to", "up", "what", "when", "use", "who", "she", "my", "his", "her"]; 11 | 12 | var tipuesearch_replace = {"words": [ 13 | {"word": "tipua", "replace_with": "tipue"}, 14 | {"word": "javscript", "replace_with": "javascript"} 15 | ]}; 16 | 17 | var tipuesearch_stem = {"words": [ 18 | {"word": "e-mail", "stem": "email"}, 19 | {"word": "javascript", "stem": "script"}, 20 | {"word": "procedure", "stem": "subroutine"}, 21 | {"word": "procedure", "stem": "function"} 22 | ]}; 23 | 24 | -------------------------------------------------------------------------------- /docs.md: -------------------------------------------------------------------------------- 1 | --- 2 | project: FPLOT 3 | summary: FPLOT is a Fortran library providing a convenient interface for plotting with GNUPLOT. 4 | project_github: https://github.com/jchristopherson/fplot 5 | author: Jason Christopherson 6 | author_email: jchristopherson@hotmail.com 7 | src_dir: ./src 8 | output_dir: ./doc 9 | display: public 10 | source: true 11 | proc_internals: true 12 | sort: permission-alpha 13 | print_creation_date: true 14 | creation_date: %Y-%m-%d %H:%M %z 15 | --- -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Example 1 2 | add_executable(generic_2d_plot generic_2d_plot.f90) 3 | target_link_libraries(generic_2d_plot fplot) 4 | 5 | # Example 2 6 | add_executable(zero_axis_example zero_axis_example.f90) 7 | target_link_libraries(zero_axis_example fplot) 8 | 9 | # Example 3 10 | add_executable(generic_3d_plot generic_3d_plot.f90) 11 | target_link_libraries(generic_3d_plot fplot) 12 | 13 | # Example 4 14 | add_executable(wireframe_surface_example wireframe_surface_example.f90) 15 | target_link_libraries(wireframe_surface_example fplot) 16 | 17 | # Example 5 18 | add_executable(png_plot_example png_plot_example.f90) 19 | target_link_libraries(png_plot_example fplot) 20 | 21 | # Example 6 22 | add_executable(latex_plot_example latex_plot_example.f90) 23 | target_link_libraries(latex_plot_example fplot) 24 | 25 | # Example 7 26 | add_executable(png_plot_example_2 png_plot_example_2.f90) 27 | target_link_libraries(png_plot_example_2 fplot) 28 | 29 | # Example 8 30 | add_executable(save_to_file_example save_to_file_example.f90) 31 | target_link_libraries(save_to_file_example fplot) 32 | 33 | # Example 9 34 | add_executable(plot_label_example plot_label_example.f90) 35 | target_link_libraries(plot_label_example fplot) 36 | 37 | # Example 10 38 | add_executable(secondary_y_axis_example secondary_y_axis_example.f90) 39 | target_link_libraries(secondary_y_axis_example fplot) 40 | 41 | # Example 11 42 | add_executable(surface_plot_example surface_plot_example.f90) 43 | target_link_libraries(surface_plot_example fplot) 44 | 45 | # Example 12 46 | add_executable(surface_plot_example_2 surface_plot_example_2.f90) 47 | target_link_libraries(surface_plot_example_2 fplot) 48 | 49 | # Example 13 50 | add_executable(multiplot_example_1 multiplot_example_1.f90) 51 | target_link_libraries(multiplot_example_1 fplot) 52 | 53 | # Example 14 54 | add_executable(multiplot_example_2 multiplot_example_2.f90) 55 | target_link_libraries(multiplot_example_2 fplot) 56 | 57 | # Example 15 58 | add_executable(log_scaling_example log_scaling_example.f90) 59 | target_link_libraries(log_scaling_example fplot) 60 | 61 | # Example 16 62 | add_executable(multiplot_save_to_file_example multiplot_save_to_file_example.f90) 63 | target_link_libraries(multiplot_save_to_file_example fplot) 64 | 65 | # Example 17 66 | add_executable(error_bar_example error_bar_example.f90) 67 | target_link_libraries(error_bar_example fplot) 68 | 69 | # Example 18 70 | add_executable(clear_plot_example clear_plot_example.f90) 71 | target_link_libraries(clear_plot_example fplot) 72 | 73 | # Example 19 74 | add_executable(triangulation_2d_example triangulation_2d_example.f90) 75 | target_link_libraries(triangulation_2d_example fplot) 76 | 77 | # Example 20 78 | add_executable(triangle_mesh_surface_example triangle_mesh_surface_example.f90) 79 | target_link_libraries(triangle_mesh_surface_example fplot) 80 | 81 | # Example 21 82 | add_executable(triangulation_2d_location_example triangulation_2d_location_example.f90) 83 | target_link_libraries(triangulation_2d_location_example fplot) 84 | 85 | # Example 22 86 | add_executable(data_dependent_colors_2d data_dependent_colors_2d.f90) 87 | target_link_libraries(data_dependent_colors_2d fplot) 88 | 89 | # Example 23 90 | add_executable(data_dependent_colors_3d data_dependent_colors_3d.f90) 91 | target_link_libraries(data_dependent_colors_3d fplot) 92 | 93 | # Example 24 94 | add_executable(vector_plot_example vector_plot_example.f90) 95 | target_link_libraries(vector_plot_example fplot) 96 | 97 | # Example 25 98 | add_executable(colored_vector_plot_example colored_vector_plot_example.f90) 99 | target_link_libraries(colored_vector_plot_example fplot) 100 | 101 | # Example 26 102 | add_executable(polar_plot_example polar_plot_example.f90) 103 | target_link_libraries(polar_plot_example fplot) 104 | 105 | # Example 27 106 | add_executable(square_axis_example square_axis_example.f90) 107 | target_link_libraries(square_axis_example fplot) 108 | 109 | # Example 28 110 | add_executable(filled_curve_example filled_curve_example.f90) 111 | target_link_libraries(filled_curve_example fplot) 112 | 113 | # Example 29 114 | add_executable(fill_between_curves_example fill_between_curves_example.f90) 115 | target_link_libraries(fill_between_curves_example fplot) 116 | 117 | # Example 30 118 | add_executable(histogram_example histogram_example.f90) 119 | target_link_libraries(histogram_example fplot) 120 | 121 | # Example 31 122 | add_executable(legend_example legend_example.f90) 123 | target_link_libraries(legend_example fplot) 124 | 125 | # Example 32 126 | add_executable(arrow_example arrow_example.f90) 127 | target_link_libraries(arrow_example fplot) 128 | 129 | # Example 33 130 | add_executable(custom_colormap_example custom_colormap_example.f90) 131 | target_link_libraries(custom_colormap_example fplot) 132 | target_link_libraries(custom_colormap_example forcolormap) 133 | 134 | # Example 34 135 | add_executable(variable_point_size_2d_example variable_point_size_2d_example.f90) 136 | target_link_libraries(variable_point_size_2d_example fplot) 137 | 138 | # Example 35 139 | add_executable(variable_point_size_3d_example variable_point_size_3d_example.f90) 140 | target_link_libraries(variable_point_size_3d_example fplot) 141 | 142 | # Example 36 143 | add_executable(correlation_plot_example correlation_plot_example.f90) 144 | target_link_libraries(correlation_plot_example fplot) 145 | 146 | # Example 37 147 | add_executable(margins_example margins_example.f90) 148 | target_link_libraries(margins_example fplot) 149 | -------------------------------------------------------------------------------- /examples/arrow_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use fplot_core 3 | use iso_fortran_env 4 | implicit none 5 | 6 | ! Local Variables 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), dimension(npts) :: x, y 9 | type(plot_2d) :: plt 10 | type(plot_data_2d) :: pd 11 | class(plot_axis), pointer :: xAxis, yAxis 12 | type(plot_arrow) :: a1, a2, a3 13 | 14 | ! Initialize the plot 15 | call plt%initialize() 16 | xAxis => plt%get_x_axis() 17 | yAxis => plt%get_y_axis() 18 | call xAxis%set_title("X Axis") 19 | call yAxis%set_title("Y Axis") 20 | 21 | ! Build a data set 22 | x = linspace(0.0d0, 1.0d1, npts) 23 | y = sin(1.0d1 * x) * sin(0.5d0 * x) 24 | call pd%define_data(x, y) 25 | call plt%push(pd) 26 | 27 | ! Define some arrows 28 | call a1%set_tail_location(0.5, 0.5) 29 | call a1%set_head_location(1.0, 1.0) 30 | call plt%push_arrow(a1) 31 | 32 | call a2%set_tail_location(0.5, 0.5) 33 | call a2%set_head_location(2.0, 0.5) 34 | call a2%set_color(CLR_RED) 35 | call a2%set_line_width(2.0) 36 | call a2%set_head_type(ARROW_HEADS) 37 | call a2%set_head_fill(ARROW_EMPTY) 38 | call a2%set_move_to_front(.false.) 39 | call plt%push_arrow(a2) 40 | 41 | call a3%set_tail_location(0.5, 0.5) 42 | call a3%set_head_location(0.5, 0.0) 43 | call a3%set_color(CLR_GREEN) 44 | call a3%set_line_width(2.0) 45 | call a3%set_head_type(ARROW_BACKHEAD) 46 | call a3%set_head_fill(ARROW_NO_FILL) 47 | call plt%push_arrow(a3) 48 | 49 | ! Draw the plot 50 | call plt%draw() 51 | end program -------------------------------------------------------------------------------- /examples/clear_plot_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: n = 1000 8 | 9 | ! Local Variables 10 | real(real64) :: x(n), y1(n), y2(n) 11 | type(plot_2d) :: plt 12 | type(plot_data_2d) :: d1, d2 13 | 14 | ! Initialization 15 | x = linspace(0.0d0, 10.0d0, n) 16 | y1 = sin(x) 17 | y2 = abs(sin(x)) 18 | 19 | ! Plot the data 20 | call plt%initialize() 21 | call d1%set_name("sin(x)") 22 | call d1%define_data(x, y1) 23 | call plt%push(d1) 24 | call plt%draw() 25 | 26 | ! Clear the first plot 27 | call plt%clear_all() 28 | 29 | ! Build the second plot 30 | call d2%set_name("|sin(x)|") 31 | call d2%define_data(x, y2) 32 | call plt%push(d2) 33 | call plt%draw() 34 | end program -------------------------------------------------------------------------------- /examples/colored_vector_plot_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Local Variables 7 | type(plot_2d) :: plt 8 | type(vector_field_plot_data) :: ds1 9 | class(plot_axis), pointer :: xAxis, yAxis 10 | type(rainbow_colormap) :: map 11 | real(real64), allocatable, dimension(:,:,:) :: pts 12 | real(real64), allocatable, dimension(:,:) :: dx, dy 13 | real(real64) :: dxdt(2) 14 | integer(int32) :: i, j 15 | 16 | ! Create a grid of points defining the vector locations 17 | pts = meshgrid( & 18 | linspace(-2.0d0, 2.0d0, 20), & 19 | linspace(-5.0d0, 5.0d0, 20)) 20 | 21 | ! Compute the values of each derivative 22 | allocate(dx(size(pts, 1), size(pts, 2))) 23 | allocate(dy(size(pts, 1), size(pts, 2))) 24 | do j = 1, size(pts, 2) 25 | do i = 1, size(pts, 1) 26 | call eqn([pts(i,j,1), pts(i,j,2)], dxdt) 27 | dx(i,j) = dxdt(1) 28 | dy(i,j) = dxdt(2) 29 | end do 30 | end do 31 | 32 | ! Define arrow properties 33 | call ds1%set_arrow_size(0.1d0) ! 1.0 by default 34 | call ds1%set_fill_arrow(.true.) ! .false. by default 35 | 36 | ! Create the plot 37 | call plt%initialize() 38 | call plt%set_font_size(14) 39 | xAxis => plt%get_x_axis() 40 | yAxis => plt%get_y_axis() 41 | 42 | ! Define axis labels 43 | call xAxis%set_title("x(t)") 44 | call yAxis%set_title("dx/dt") 45 | 46 | ! Set plot style information 47 | call xAxis%set_zero_axis(.true.) 48 | call yAxis%set_zero_axis(.true.) 49 | call plt%set_draw_border(.false.) 50 | call plt%set_show_gridlines(.false.) 51 | 52 | ! Define the colormap 53 | call plt%set_colormap(map) 54 | 55 | ! Add the data to the plot - color by the magnitude of gradient 56 | call ds1%define_data(pts(:,:,1), pts(:,:,2), dx, dy, sqrt(dx**2 + dy**2)) 57 | call plt%push(ds1) 58 | 59 | call plt%draw() 60 | contains 61 | ! Van der Pol Equation 62 | ! x" - mu * (1 - x^2) * x' + x = 0 63 | subroutine eqn(x, dxdt) 64 | real(real64), intent(in) :: x(2) 65 | real(real64), intent(out) :: dxdt(2) 66 | 67 | real(real64), parameter :: mu = 2.0d0 68 | 69 | dxdt(1) = x(2) 70 | dxdt(2) = mu * (1.0d0 - x(1)**2) * x(2) - x(1) 71 | end subroutine 72 | end program 73 | -------------------------------------------------------------------------------- /examples/correlation_plot_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: npts = 1000 8 | integer(int32), parameter :: nparams = 3 9 | 10 | ! Local Variables 11 | type(correlation_plot) :: plt 12 | real(real64) :: m, x(npts, nparams) 13 | 14 | ! Generate some data 15 | call random_number(m) 16 | call random_number(x) 17 | x(:,2) = m * x(:,1) * (1.0d0 + 0.5d0 * x(:,1)) + 0.1d0 * (x(:,2) - 1.0d0) 18 | x(:,3) = 1.0d-2 * x(:,3) / (x(:,2) + 1.5d0) 19 | 20 | ! Create the plot 21 | call plt%initialize(x, width = 1200, height = 800) 22 | call plt%draw() 23 | end program -------------------------------------------------------------------------------- /examples/custom_colormap_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use fplot_core 3 | use iso_fortran_env 4 | use forcolormap, only : colormaps_list 5 | implicit none 6 | 7 | ! Parameters 8 | integer(int32), parameter :: m = 50 9 | integer(int32), parameter :: n = 50 10 | 11 | ! Local Variables 12 | real(real64), dimension(m, n, 2), target :: xy 13 | real(real64), pointer, dimension(:,:) :: x, y 14 | real(real64), dimension(m, n) :: z 15 | type(surface_plot) :: plt 16 | type(surface_plot_data) :: d1 17 | class(plot_axis), pointer :: xAxis, yAxis, zAxis 18 | type(custom_colormap) :: map 19 | type(cmap) :: colors 20 | 21 | ! Set up the colormap 22 | call colors%set("glasgow", -8.0d0, 8.0d0) 23 | call map%set_colormap(colors) 24 | 25 | ! Define the data 26 | xy = meshgrid(linspace(-5.0d0, 5.0d0, n), linspace(-5.0d0, 5.0d0, m)) 27 | x => xy(:,:,1) 28 | y => xy(:,:,2) 29 | 30 | ! Initialize the plot 31 | call plt%initialize() 32 | call plt%set_colormap(map) 33 | 34 | ! Establish lighting 35 | call plt%set_use_lighting(.true.) 36 | 37 | ! Set the orientation of the plot 38 | call plt%set_elevation(20.0d0) 39 | call plt%set_azimuth(30.0d0) 40 | 41 | ! Define titles 42 | call plt%set_title("Example Plot") 43 | 44 | xAxis => plt%get_x_axis() 45 | call xAxis%set_title("X Axis") 46 | 47 | yAxis => plt%get_y_axis() 48 | call yAxis%set_title("Y Axis") 49 | 50 | zAxis => plt%get_z_axis() 51 | call zAxis%set_title("Z Axis") 52 | 53 | ! Define the function to plot 54 | z = sqrt(x**2 + y**2) * sin(x**2 + y**2) 55 | call d1%define_data(x, y, z) 56 | call plt%push(d1) 57 | 58 | ! Draw the plot 59 | call plt%draw() 60 | end program -------------------------------------------------------------------------------- /examples/data_dependent_colors_2d.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: npts = 1000 8 | 9 | ! Local Variables 10 | real(real64) :: x(npts), y(npts) 11 | type(plot_2d) :: plt 12 | type(plot_data_2d) :: ds 13 | type(cool_colormap) :: map 14 | 15 | ! Build the data set 16 | x = linspace(0.0d0, 1.0d1, npts) 17 | y = exp(-0.2 * x) * sin(10.0d0 * x) * cos(5.0d0 * x) 18 | 19 | ! Plot the data set 20 | call plt%initialize() 21 | call plt%set_colormap(map) 22 | call plt%set_font_size(14) 23 | call ds%define_data(x, y, y) 24 | call ds%set_line_width(3.0) 25 | call plt%push(ds) 26 | call plt%draw() 27 | end program 28 | -------------------------------------------------------------------------------- /examples/data_dependent_colors_3d.f90: -------------------------------------------------------------------------------- 1 | ! fplot_3d_clr_1.f90 2 | 3 | program example 4 | use, intrinsic :: iso_fortran_env 5 | use fplot_core 6 | implicit none 7 | 8 | ! Parameters 9 | integer(int32), parameter :: n = 1000 10 | 11 | ! Local Variables 12 | real(real64), dimension(n) :: t, x, y, z 13 | type(plot_3d) :: plt 14 | type(plot_data_3d) :: d1 15 | class(plot_axis), pointer :: xAxis, yAxis, zAxis 16 | 17 | ! Initialize the plot object 18 | call plt%initialize() 19 | call plt%set_font_size(14) 20 | 21 | ! Define titles 22 | call plt%set_title("Example Plot") 23 | 24 | xAxis => plt%get_x_axis() 25 | call xAxis%set_title("X Axis") 26 | 27 | yAxis => plt%get_y_axis() 28 | call yAxis%set_title("Y Axis") 29 | 30 | zAxis => plt%get_z_axis() 31 | call zAxis%set_title("Z Axis") 32 | 33 | ! Define the data 34 | t = linspace(0.0d0, 10.0d0, n) 35 | x = cos(5.0d0 * t) 36 | y = sin(5.0d0 * t) 37 | z = 2.0d0 * t 38 | 39 | call d1%define_data(x, y, z, x * y) 40 | 41 | ! Set up the data set 42 | call d1%set_line_width(2.0) 43 | 44 | ! Add the data to the plot 45 | call plt%push(d1) 46 | 47 | ! Let GNUPLOT draw the plot 48 | call plt%draw() 49 | end program 50 | -------------------------------------------------------------------------------- /examples/error_bar_example.f90: -------------------------------------------------------------------------------- 1 | ! fplot_err_1.f90 2 | 3 | program example 4 | use iso_fortran_env 5 | use fplot_core 6 | implicit none 7 | 8 | ! Parameters 9 | integer(int32), parameter :: n = 50 10 | 11 | ! Local Variables 12 | real(real64) :: x(n), y(n), yerr(n) 13 | type(plot_2d) :: plt 14 | type(plot_data_2d) :: d1 15 | type(plot_data_error_bars) :: e1 16 | 17 | ! Initialization 18 | x = linspace(0.0d0, 1.0d1, n) 19 | y = sin(x) 20 | call random_number(yerr) 21 | yerr = 3.0d-1 * (yerr - 0.5d0) 22 | 23 | ! Create the plot 24 | call plt% initialize() 25 | 26 | call d1%define_data(x, y) 27 | call d1%set_name("Raw") 28 | 29 | call e1%define_y_error_data(x, y, yerr) 30 | call e1%set_name("Errors") 31 | 32 | call plt%push(d1) 33 | call plt%push(e1) 34 | call plt%draw() 35 | end program -------------------------------------------------------------------------------- /examples/fill_between_curves_example.f90: -------------------------------------------------------------------------------- 1 | ! fplot_fill_2.f90 2 | 3 | program example 4 | use iso_fortran_env 5 | use fplot_core 6 | implicit none 7 | 8 | ! Local Variables 9 | integer(int32), parameter :: npts = 100 10 | real(real64), parameter :: pi = 2.0d0 * acos(0.0d0) 11 | real(real64) :: x(npts), y(npts) 12 | type(plot_2d) :: plt 13 | type(filled_plot_data) :: pd 14 | 15 | ! Generate the curve to plot 16 | x = linspace(0.0d0, 1.0d0, npts) 17 | y = sin(4.0d0 * pi * x) 18 | 19 | ! Plot the data 20 | call plt%initialize() 21 | 22 | call pd%define_data(x, y, 0.25d0 * y) 23 | 24 | call plt%push(pd) 25 | call plt%draw() 26 | end program 27 | -------------------------------------------------------------------------------- /examples/filled_curve_example.f90: -------------------------------------------------------------------------------- 1 | ! fplot_fill_1.f90 2 | 3 | program example 4 | use iso_fortran_env 5 | use fplot_core 6 | implicit none 7 | 8 | ! Local Variables 9 | integer(int32), parameter :: npts = 100 10 | real(real64), parameter :: pi = 2.0d0 * acos(0.0d0) 11 | real(real64) :: x(npts), y(npts) 12 | type(plot_2d) :: plt 13 | type(plot_data_2d) :: pd 14 | 15 | ! Generate the curve to plot 16 | x = linspace(0.0d0, 1.0d0, npts) 17 | y = sin(4.0d0 * pi * x) 18 | 19 | ! Plot the data 20 | call plt%initialize() 21 | 22 | call pd%define_data(x, y) 23 | call pd%set_fill_curve(.true.) 24 | call plt%push(pd) 25 | 26 | call pd%define_data(x, -0.25d0 * y) 27 | call pd%set_fill_curve(.true.) 28 | call plt%push(pd) 29 | 30 | call plt%draw() 31 | end program 32 | -------------------------------------------------------------------------------- /examples/generic_2d_plot.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use, intrinsic :: iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: n = 1000 8 | 9 | ! Local Variables 10 | real(real64), dimension(n) :: x, y1, y2 11 | type(plot_2d) :: plt 12 | type(plot_data_2d) :: d1, d2 13 | class(plot_axis), pointer :: xAxis, yAxis 14 | type(legend), pointer :: leg 15 | 16 | ! Initialize the plot object 17 | call plt%initialize() 18 | 19 | ! Define titles 20 | call plt%set_title("Example Plot") 21 | call plt%set_font_size(14) 22 | 23 | xAxis => plt%get_x_axis() 24 | call xAxis%set_title("X Axis") 25 | 26 | yAxis => plt%get_y_axis() 27 | call yAxis%set_title("Y Axis") 28 | 29 | ! Establish legend properties 30 | leg => plt%get_legend() 31 | call leg%set_is_visible(.true.) 32 | call leg%set_draw_inside_axes(.false.) 33 | call leg%set_horizontal_position(LEGEND_CENTER) 34 | call leg%set_vertical_position(LEGEND_BOTTOM) 35 | call leg%set_draw_border(.false.) 36 | 37 | ! Define the data, and then add it to the plot 38 | x = linspace(0.0d0, 10.0d0, n) 39 | y1 = sin(5.0d0 * x) 40 | y2 = 2.0d0 * cos(2.0d0 * x) 41 | 42 | call d1%define_data(x, y1) 43 | call d2%define_data(x, y2) 44 | 45 | ! Define properties for each data set 46 | call d1%set_name("Data Set 1") 47 | call d1%set_draw_markers(.true.) 48 | call d1%set_marker_frequency(10) 49 | call d1%set_marker_style(MARKER_EMPTY_CIRCLE) 50 | call d1%set_marker_scaling(2.0) 51 | 52 | call d2%set_name("Data Set 2") 53 | call d2%set_line_style(LINE_DASHED) 54 | call d2%set_line_width(2.0) 55 | 56 | ! Add the data sets to the plot 57 | call plt%push(d1) 58 | call plt%push(d2) 59 | 60 | ! Let GNUPLOT draw the plot 61 | call plt%draw() 62 | end program -------------------------------------------------------------------------------- /examples/generic_3d_plot.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use, intrinsic :: iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: n = 1000 8 | 9 | ! Local Variables 10 | real(real64), dimension(n) :: t, x, y, z 11 | type(plot_3d) :: plt 12 | type(plot_data_3d) :: d1 13 | class(plot_axis), pointer :: xAxis, yAxis, zAxis 14 | 15 | ! Initialize the plot object 16 | call plt%initialize() 17 | 18 | ! Define titles 19 | call plt%set_title("Example Plot") 20 | 21 | xAxis => plt%get_x_axis() 22 | call xAxis%set_title("X Axis") 23 | 24 | yAxis => plt%get_y_axis() 25 | call yAxis%set_title("Y Axis") 26 | 27 | zAxis => plt%get_z_axis() 28 | call zAxis%set_title("Z Axis") 29 | 30 | ! Define the data 31 | t = linspace(0.0d0, 10.0d0, n) 32 | x = cos(5.0d0 * t) 33 | y = sin(5.0d0 * t) 34 | z = 2.0d0 * t 35 | 36 | call d1%define_data(x, y, z) 37 | call d1%set_line_width(2.0) 38 | 39 | ! Add the data to the plot 40 | call plt%push(d1) 41 | 42 | ! Let GNUPLOT draw the plot 43 | call plt%draw() 44 | end program -------------------------------------------------------------------------------- /examples/histogram_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Local Variables 7 | integer(int32), parameter :: n = 5000 8 | integer(int32), parameter :: nbins = 30 9 | real(real64) :: x(n), u(n), v(n) 10 | type(plot_2d) :: plt 11 | type(plot_data_histogram) :: pd1 12 | class(plot_axis), pointer :: xAxis 13 | 14 | ! Initialization 15 | call plt%initialize() 16 | xAxis => plt%get_x_axis() 17 | 18 | ! Create some data 19 | call random_number(u) 20 | call random_number(v) 21 | v = v - 1.0d0 22 | x = u * u - v * v 23 | 24 | ! Rotate the labels on the x axis 25 | call xAxis%set_tic_label_angle(90.0) 26 | call xAxis%set_tic_label_rotation_origin(GNUPLOT_ROTATION_ORIGIN_RIGHT) 27 | 28 | ! Plot the data 29 | call pd1%set_bin_count(nbins) ! optional, but must be done prior to define_data is used 30 | call pd1%define_data(x) 31 | call plt%push(pd1) 32 | call plt%draw() 33 | end program -------------------------------------------------------------------------------- /examples/latex_plot_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Local Variables & Parameters 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), dimension(npts) :: x, y1, y2 9 | type(plot_2d) :: plt 10 | class(terminal), pointer :: term 11 | type(plot_data_2d) :: d1, d2 12 | class(plot_axis), pointer :: xAxis, yAxis 13 | type(legend), pointer :: leg 14 | 15 | ! Build a data set to plot 16 | x = linspace(0.0d0, 10.0d0, npts) 17 | y1 = sin(x) * cos(x) 18 | y2 = sqrt(x) * sin(x) 19 | 20 | call d1%define_data(x, y1) 21 | call d2%define_data(x, y2) 22 | 23 | ! Set up the plot 24 | call plt%initialize(GNUPLOT_TERMINAL_LATEX) ! Save to file directly 25 | call plt%set_title("Example Plot") 26 | 27 | xAxis => plt%get_x_axis() 28 | call xAxis%set_title("X Axis") 29 | 30 | yAxis => plt%get_y_axis() 31 | call yAxis%set_title("Y Axis") 32 | 33 | ! Put the legend in the upper left corner of the plot 34 | leg => plt%get_legend() 35 | call leg%set_is_visible(.true.) 36 | call leg%set_horizontal_position(LEGEND_LEFT) 37 | call leg%set_vertical_position(LEGEND_TOP) 38 | 39 | ! Set up line color and style properties to better distinguish each data set 40 | call d1%set_name("Data Set 1") 41 | call d1%set_line_color(CLR_BLUE) 42 | 43 | call d2%set_name("Data Set 2") 44 | call d2%set_line_color(CLR_GREEN) 45 | 46 | ! Add the data to the plot 47 | call plt%push(d1) 48 | call plt%push(d2) 49 | 50 | ! Define the file to which the plot should be saved 51 | term => plt%get_terminal() 52 | select type (term) 53 | class is (latex_terminal) 54 | print '(A)', "LATEX TERMINAL" 55 | call term%set_filename("example_latex_plot.tex") 56 | end select 57 | 58 | ! Draw the plot 59 | call plt%draw() 60 | end program -------------------------------------------------------------------------------- /examples/legend_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use fplot_core 3 | use iso_fortran_env 4 | implicit none 5 | 6 | ! Local Variables & Parameters 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), dimension(npts) :: x, y 9 | type(plot_2d) :: plt 10 | type(plot_data_2d) :: dataset 11 | class(plot_axis), pointer :: xAxis, yAxis 12 | type(legend), pointer :: leg 13 | 14 | ! Build a data set to plot 15 | x = linspace(0.0d0, 10.0d0, npts) 16 | y = exp(-0.5d0 * x) * sin(10.0d0 * x - 0.5d0) 17 | 18 | call dataset%define_data(x, y) 19 | call dataset%set_name("Example") 20 | 21 | ! Set up the plot 22 | call plt%initialize() 23 | call plt%set_title("Example Plot") 24 | 25 | xAxis => plt%get_x_axis() 26 | call xAxis%set_title("X Axis") 27 | 28 | yAxis => plt%get_y_axis() 29 | call yAxis%set_title("Y Axis") 30 | 31 | ! Show the legend 32 | leg => plt%get_legend() 33 | call leg%set_is_visible(.true.) 34 | call leg%set_is_opaque(.false.) 35 | call leg%set_draw_border(.false.) 36 | call leg%set_horizontal_position(LEGEND_RIGHT) 37 | call leg%set_vertical_position(LEGEND_BOTTOM) 38 | 39 | ! Add the data to the plot 40 | call plt%push(dataset) 41 | 42 | ! Draw the plot 43 | call plt%draw() 44 | end program -------------------------------------------------------------------------------- /examples/log_scaling_example.f90: -------------------------------------------------------------------------------- 1 | ! This example illustrates the frequency response of the following mechanical 2 | ! system. 3 | ! 4 | ! -> y |-> x1 |-> x2 5 | ! | |/ 6 | ! |-/\/\/\-| m |-/\/\/\-| m |-/\/\/\-|/ 7 | ! | k, b k, b k, b |/ 8 | ! 9 | ! The equations of motion for this system are as follows. 10 | ! M x" + B x' + K x = F1 y' + F2 y 11 | ! 12 | ! Where: 13 | ! | m 0 | 14 | ! M = | | 15 | ! | 0 m | 16 | ! 17 | ! | 2b -b | 18 | ! B = | | 19 | ! | -b 2b | 20 | ! 21 | ! | 2k -k | 22 | ! K = | | 23 | ! | -k 2k | 24 | ! 25 | ! | b | 26 | ! F1 = | | 27 | ! | 0 | 28 | ! 29 | ! | k | 30 | ! F2 = | | 31 | ! | 0 | 32 | ! 33 | ! The solution may be computed by applying the Laplace transform such that: 34 | ! (M s**2 + B s + K) X = (F1 s + F2) Y 35 | ! 36 | ! And then solving for X / Y such that: 37 | ! Z = X / Y = inv(M s**2 + B s + K) * (F1 s + F2) 38 | program example 39 | use iso_fortran_env 40 | use fplot_core 41 | implicit none 42 | 43 | ! Parameters 44 | real(real64), parameter :: m = 2.0d0 45 | real(real64), parameter :: k = 450.0d3 46 | real(real64), parameter :: b = 3.0d0 47 | real(real64), parameter :: pi = 3.1415926535897932384626433832795d0 48 | integer(int32), parameter :: npts = 1000 49 | complex(real64), parameter :: j = (0.0d0, -1.0d0) 50 | 51 | ! Local Variables 52 | complex(real64), dimension(npts) :: s, z1, z2 53 | real(real64), dimension(npts) :: freq, omega 54 | type(plot_2d) :: plt 55 | type(plot_data_2d) :: d1, d2 56 | class(plot_axis), pointer :: xAxis, yAxis 57 | class(legend), pointer :: lgnd 58 | 59 | ! Generate a frequency vector from 10 Hz to 1 kHz 60 | freq = logspace(1.0d0, 3.0d0, npts) 61 | omega = 2.0d0 * pi * freq 62 | s = j * omega 63 | 64 | ! Compute the frequency response functions for each mass 65 | z1 = (b * s + k) * (m * s**2 + 2.0d0 * b * s + 2.0d0 * k) / & 66 | ((m * s**2 + 2.0d0 * b * s + 2.0d0 * k)**2 + (-b * s - k) * (b * s + k)) 67 | z2 = (b * s + k)**2 / & 68 | ((m * s**2 + 2.0d0 * b * s + 2.0d0 * k)**2 + (-b * s - k) * (b * s + k)) 69 | 70 | ! Create the plot 71 | call plt%initialize() 72 | call plt%set_font_size(14) 73 | xAxis => plt%get_x_axis() 74 | yAxis => plt%get_y_axis() 75 | lgnd => plt%get_legend() 76 | 77 | call lgnd%set_is_visible(.true.) 78 | call lgnd%set_draw_border(.false.) 79 | 80 | call xAxis%set_title("Frequency [Hz]") 81 | call yAxis%set_title("Amplitude (X / Y)") 82 | 83 | call xAxis%set_is_log_scaled(.true.) 84 | call yAxis%set_is_log_scaled(.true.) 85 | 86 | call xAxis%set_use_default_tic_label_format(.false.) 87 | call xAxis%set_tic_label_format("%0.0e") 88 | 89 | call yAxis%set_use_default_tic_label_format(.false.) 90 | call yAxis%set_tic_label_format("%0.0e") 91 | 92 | call d1%set_name("X1") 93 | call d1%set_line_width(2.0) 94 | call d1%define_data(freq, abs(z1)) 95 | 96 | call d2%set_name("X2") 97 | call d2%set_line_width(2.0) 98 | call d2%set_line_style(LINE_DASHED) 99 | call d2%define_data(freq, abs(z2)) 100 | 101 | call plt%push(d1) 102 | call plt%push(d2) 103 | call plt%draw() 104 | end program -------------------------------------------------------------------------------- /examples/margins_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use, intrinsic :: iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: n = 1000 8 | 9 | ! Local Variables 10 | real(real64), dimension(n) :: x, y1, y2 11 | type(plot_2d) :: plt 12 | type(plot_data_2d) :: d1, d2 13 | class(plot_axis), pointer :: xAxis, yAxis 14 | type(legend), pointer :: leg 15 | 16 | ! Initialize the plot object 17 | call plt%initialize() 18 | 19 | ! Define titles 20 | call plt%set_title("Example Plot") 21 | call plt%set_font_size(14) 22 | 23 | xAxis => plt%get_x_axis() 24 | call xAxis%set_title("X Axis") 25 | 26 | yAxis => plt%get_y_axis() 27 | call yAxis%set_title("Y Axis") 28 | 29 | ! Set margins 30 | call plt%set_left_margin(0.25) 31 | call plt%set_right_margin(0.75) 32 | call plt%set_top_margin(0.75) 33 | call plt%set_bottom_margin(0.35) 34 | 35 | ! Establish legend properties 36 | leg => plt%get_legend() 37 | call leg%set_is_visible(.true.) 38 | call leg%set_draw_inside_axes(.false.) 39 | call leg%set_horizontal_position(LEGEND_CENTER) 40 | call leg%set_vertical_position(LEGEND_BOTTOM) 41 | call leg%set_draw_border(.false.) 42 | 43 | ! Define the data, and then add it to the plot 44 | x = linspace(0.0d0, 10.0d0, n) 45 | y1 = sin(5.0d0 * x) 46 | y2 = 2.0d0 * cos(2.0d0 * x) 47 | 48 | call d1%define_data(x, y1) 49 | call d2%define_data(x, y2) 50 | 51 | ! Define properties for each data set 52 | call d1%set_name("Data Set 1") 53 | call d1%set_draw_markers(.true.) 54 | call d1%set_marker_frequency(10) 55 | call d1%set_marker_style(MARKER_EMPTY_CIRCLE) 56 | call d1%set_marker_scaling(2.0) 57 | 58 | call d2%set_name("Data Set 2") 59 | call d2%set_line_style(LINE_DASHED) 60 | call d2%set_line_width(2.0) 61 | 62 | ! Add the data sets to the plot 63 | call plt%push(d1) 64 | call plt%push(d2) 65 | 66 | ! Let GNUPLOT draw the plot 67 | call plt%draw() 68 | end program -------------------------------------------------------------------------------- /examples/meson.build: -------------------------------------------------------------------------------- 1 | examples = [ 2 | ['fplot_2d_1','fplot_2d_1.f90'], 3 | ['fplot_2d_2','fplot_2d_2.f90'], 4 | ['fplot_2d_3','fplot_2d_3.f90'], 5 | ['fplot_2d_4','fplot_2d_4.f90'], 6 | ['fplot_2d_5','fplot_2d_5.f90'], 7 | ['fplot_2d_6','fplot_2d_6.f90'], 8 | ['fplot_2d_7','fplot_2d_7.f90'], 9 | ['fplot_2d_8','fplot_2d_8.f90'], 10 | ['fplot_2d_9','fplot_2d_9.f90'], 11 | ['fplot_2d_clr_1','fplot_2d_clr_1.f90'], 12 | ['fplot_3d_1','fplot_3d_1.f90'], 13 | ['fplot_3d_clr_1','fplot_3d_clr_1.f90'], 14 | ['fplot_clear_1','fplot_clear_1.f90'], 15 | ['fplot_d2d_1','fplot_d2d_1.f90'], 16 | ['fplot_d2d_2','fplot_d2d_2.f90'], 17 | ['fplot_err_1','fplot_err_1.f90'], 18 | ['fplot_fill_1','fplot_fill_1.f90'], 19 | ['fplot_fill_2','fplot_fill_2.f90'], 20 | ['fplot_log_1','fplot_log_1.f90'], 21 | ['fplot_multi_1','fplot_multi_1.f90'], 22 | ['fplot_multi_2','fplot_multi_2.f90'], 23 | ['fplot_multi_3','fplot_multi_3.f90'], 24 | ['fplot_png_1','fplot_png_1.f90'], 25 | ['fplot_polar_1','fplot_polar_1.f90'], 26 | ['fplot_surf_1','fplot_surf_1.f90'], 27 | ['fplot_surf_2','fplot_surf_2.f90'], 28 | ['fplot_surf_3','fplot_surf_3.f90'], 29 | ['fplot_tri_surf_1','fplot_tri_surf_1.f90'], 30 | ['fplot_vector_1','fplot_vector_1.f90'], 31 | ['fplot_vector_2','fplot_vector_2.f90'] 32 | ] 33 | 34 | foreach example : examples 35 | executable(example[0], example[1], 36 | dependencies: fplot_dep) 37 | endforeach 38 | -------------------------------------------------------------------------------- /examples/multiplot_example_1.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Variables 7 | integer(int32), parameter :: n = 1000 8 | real(real64), allocatable, dimension(:) :: x1, y1, x2, y2 9 | type(multiplot) :: mplt 10 | type(plot_2d) :: plt1, plt2 11 | type(plot_data_2d) :: d1, d2 12 | class(plot_axis), pointer :: x1Axis, x2Axis, y1Axis, y2Axis 13 | 14 | ! Build the data sets 15 | x1 = linspace(0.0d0, 5.0d0, n) 16 | x2 = linspace(0.0d0, 10.0d0, n) 17 | y1 = exp(-0.1d0 * x1) * sin(20.0d0 * x1) 18 | y2 = exp(-0.2d0 * x2) * sin(15.0d0 * x2) + 0.1d0 * sin(75.0d0 * x2) 19 | 20 | ! Define the plots 21 | call mplt%initialize(2, 1) 22 | call mplt%set_font_size(14) 23 | call plt1%initialize() 24 | call plt2%initialize() 25 | 26 | x1Axis => plt1%get_x_axis() 27 | y1Axis => plt1%get_y_axis() 28 | 29 | x2Axis => plt2%get_x_axis() 30 | y2Axis => plt2%get_y_axis() 31 | 32 | call x1Axis%set_title("X1") 33 | call y1Axis%set_title("Y1") 34 | 35 | call x2Axis%set_title("X2") 36 | call y2Axis%set_title("Y2") 37 | 38 | call d1%set_name("Data Set 1") 39 | call d1%set_line_width(2.0) 40 | call d1%define_data(x1, y1) 41 | 42 | call d2%set_name("Data Set 2") 43 | call d2%set_line_width(2.0) 44 | call d2%define_data(x2, y2) 45 | 46 | call plt1%push(d1) 47 | call plt2%push(d2) 48 | 49 | call mplt%set(1, 1, plt1) 50 | call mplt%set(2, 1, plt2) 51 | call mplt%draw() 52 | end program -------------------------------------------------------------------------------- /examples/multiplot_example_2.f90: -------------------------------------------------------------------------------- 1 | ! fplot_multi_2.f90 2 | 3 | program example 4 | use iso_fortran_env 5 | use fplot_core 6 | implicit none 7 | 8 | ! Variables 9 | integer(int32), parameter :: n = 1000 10 | real(real64), allocatable, dimension(:) :: x1, y1, x2, y2, x3, y3, x4, y4 11 | type(multiplot) :: mplt 12 | type(plot_2d) :: plt1, plt2, plt3, plt4 13 | type(plot_data_2d) :: d1, d2, d3, d4 14 | 15 | ! Build the data sets 16 | x1 = linspace(0.0d0, 1.0d0, n) 17 | x2 = linspace(0.0d0, 2.0d0, n) 18 | x3 = linspace(0.0d0, 3.0d0, n) 19 | x4 = linspace(0.0d0, 4.0d0, n) 20 | y1 = sin(20.0d0 * x1) 21 | y2 = sin(20.0d0 * x2) * cos(50.0d0 * x2) 22 | y3 = sqrt(x3) * sin(10.0d0 * x3) 23 | y4 = exp(-0.1d0 * x4) * sin(15.0d0 * x4) 24 | 25 | ! Define the plots 26 | call mplt%initialize(2, 2) 27 | call plt1%initialize() 28 | call plt2%initialize() 29 | call plt3%initialize() 30 | call plt4%initialize() 31 | 32 | call d1%define_data(x1, y1) 33 | call d2%define_data(x2, y2) 34 | call d3%define_data(x3, y3) 35 | call d4%define_data(x4, y4) 36 | 37 | call plt1%push(d1) 38 | call plt1%set_title("Plot 1 (1, 1)") 39 | 40 | call plt2%push(d2) 41 | call plt2%set_title("Plot 2 (2, 1)") 42 | 43 | call plt3%push(d3) 44 | call plt3%set_title("Plot 3 (1, 2)") 45 | 46 | call plt4%push(d4) 47 | call plt4%set_title("Plot 4 (2, 2)") 48 | 49 | call mplt%set(1, 1, plt1) 50 | call mplt%set(2, 1, plt2) 51 | call mplt%set(1, 2, plt3) 52 | call mplt%set(2, 2, plt4) 53 | call mplt%draw() 54 | end program -------------------------------------------------------------------------------- /examples/multiplot_save_to_file_example.f90: -------------------------------------------------------------------------------- 1 | ! This example illustrates the frequency response of the following mechanical 2 | ! system. 3 | ! 4 | ! -> y |-> x1 |-> x2 5 | ! | |/ 6 | ! |-/\/\/\-| m |-/\/\/\-| m |-/\/\/\-|/ 7 | ! | k, b k, b k, b |/ 8 | ! 9 | ! The equations of motion for this system are as follows. 10 | ! M x" + B x' + K x = F1 y' + F2 y 11 | ! 12 | ! Where: 13 | ! | m 0 | 14 | ! M = | | 15 | ! | 0 m | 16 | ! 17 | ! | 2b -b | 18 | ! B = | | 19 | ! | -b 2b | 20 | ! 21 | ! | 2k -k | 22 | ! K = | | 23 | ! | -k 2k | 24 | ! 25 | ! | b | 26 | ! F1 = | | 27 | ! | 0 | 28 | ! 29 | ! | k | 30 | ! F2 = | | 31 | ! | 0 | 32 | ! 33 | ! The solution may be computed by applying the Laplace transform such that: 34 | ! (M s**2 + B s + K) X = (F1 s + F2) Y 35 | ! 36 | ! And then solving for X / Y such that: 37 | ! Z = X / Y = inv(M s**2 + B s + K) * (F1 s + F2) 38 | program example 39 | use iso_fortran_env 40 | use fplot_core 41 | implicit none 42 | 43 | ! Parameters 44 | real(real64), parameter :: m = 2.0d0 45 | real(real64), parameter :: k = 450.0d3 46 | real(real64), parameter :: b = 3.0d0 47 | real(real64), parameter :: pi = 3.1415926535897932384626433832795d0 48 | integer(int32), parameter :: npts = 1000 49 | complex(real64), parameter :: j = (0.0d0, -1.0d0) 50 | 51 | ! Local Variables 52 | complex(real64), dimension(npts) :: s, z1, z2 53 | real(real64), dimension(npts) :: freq, omega 54 | type(multiplot) :: mplt 55 | type(plot_2d) :: plt, pplt 56 | type(plot_data_2d) :: d1, d2, d3, d4 57 | class(plot_axis), pointer :: xAxis, yAxis 58 | class(legend), pointer :: lgnd 59 | 60 | ! Generate a frequency vector from 10 Hz to 1 kHz 61 | freq = logspace(1.0d0, 3.0d0, npts) 62 | omega = 2.0d0 * pi * freq 63 | s = j * omega 64 | 65 | ! Compute the frequency response functions for each mass 66 | z1 = (b * s + k) * (m * s**2 + 2.0d0 * b * s + 2.0d0 * k) / & 67 | ((m * s**2 + 2.0d0 * b * s + 2.0d0 * k)**2 + (-b * s - k) * (b * s + k)) 68 | z2 = (b * s + k)**2 / & 69 | ((m * s**2 + 2.0d0 * b * s + 2.0d0 * k)**2 + (-b * s - k) * (b * s + k)) 70 | 71 | ! Create the plots 72 | call mplt%initialize(2, 1) 73 | call mplt%set_font_size(14) 74 | call plt%initialize() 75 | xAxis => plt%get_x_axis() 76 | yAxis => plt%get_y_axis() 77 | lgnd => plt%get_legend() 78 | 79 | call lgnd%set_is_visible(.true.) 80 | 81 | call xAxis%set_title("Frequency [Hz]") 82 | call yAxis%set_title("Amplitude (X / Y)") 83 | 84 | call xAxis%set_is_log_scaled(.true.) 85 | call yAxis%set_is_log_scaled(.true.) 86 | 87 | call d1%set_name("X1") 88 | call d1%set_line_width(2.0) 89 | call d1%define_data(freq, abs(z1)) 90 | 91 | call d2%set_name("X2") 92 | call d2%set_line_width(2.0) 93 | call d2%set_line_style(LINE_DASHED) 94 | call d2%define_data(freq, abs(z2)) 95 | 96 | call plt%push(d1) 97 | call plt%push(d2) 98 | 99 | ! Set up the phase plot 100 | call pplt%initialize() 101 | xAxis => pplt%get_x_axis() 102 | yAxis => pplt%get_y_axis() 103 | 104 | call xAxis%set_title("Frequency [Hz]") 105 | call yAxis%set_title("Phase [deg]") 106 | 107 | call xAxis%set_is_log_scaled(.true.) 108 | 109 | call d3%set_name("X1") 110 | call d3%set_line_width(2.0) 111 | call d3%define_data(freq, 180.0d0 * atan2(aimag(z1), real(z1)) / pi) 112 | 113 | call d4%set_name("X2") 114 | call d4%set_line_width(2.0) 115 | call d4%set_line_style(LINE_DASHED) 116 | call d4%define_data(freq, 180.0d0 * atan2(aimag(z2), real(z2)) / pi) 117 | 118 | call pplt%push(d3) 119 | call pplt%push(d4) 120 | 121 | ! Save the plot to file 122 | call mplt%set(1, 1, plt) 123 | call mplt%set(2, 1, pplt) 124 | call mplt%save_file("example_multiplot_file.plt") 125 | end program 126 | -------------------------------------------------------------------------------- /examples/plot_label_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use fplot_core 3 | use iso_fortran_env 4 | implicit none 5 | 6 | ! Local Variables 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), dimension(npts) :: x, y 9 | type(plot_2d) :: plt 10 | type(plot_data_2d) :: dataset 11 | class(plot_axis), pointer :: xAxis, yAxis 12 | type(plot_label) :: lbl 13 | 14 | ! Build a data set 15 | x = linspace(0.0d0, 10.0d0, npts) 16 | y = sin(10.0d0 * x) * sin(0.5d0 * x) 17 | 18 | call dataset%define_data(y) 19 | 20 | ! Define the label 21 | call lbl%set_text("Test Label 1") 22 | call lbl%set_position([600.0, 0.6, 0.0]) 23 | 24 | ! Set up the plot 25 | call plt%initialize() 26 | call plt%set_title("Example Plot") 27 | call plt%set_font_size(14) 28 | call plt%set_show_gridlines(.false.) 29 | 30 | ! Add the label to the plot 31 | call plt%push_label(lbl) 32 | 33 | xAxis => plt%get_x_axis() 34 | call xAxis%set_title("X Axis") 35 | 36 | yAxis => plt%get_y_axis() 37 | call yAxis%set_title("Y Axis") 38 | 39 | ! Add the data to the plot 40 | call plt%push(dataset) 41 | 42 | ! Draw 43 | call plt%draw() 44 | end program 45 | -------------------------------------------------------------------------------- /examples/png_plot_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Local Variables & Parameters 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), dimension(npts) :: x, y1, y2 9 | type(plot_2d) :: plt 10 | type(plot_data_2d) :: d1, d2 11 | class(plot_axis), pointer :: xAxis, yAxis 12 | type(legend), pointer :: leg 13 | 14 | ! Build a data set to plot 15 | x = linspace(0.0d0, 10.0d0, npts) 16 | y1 = sin(x) * cos(x) 17 | y2 = sqrt(x) * sin(x) 18 | 19 | call d1%define_data(x, y1) 20 | call d2%define_data(x, y2) 21 | 22 | ! Set up the plot 23 | call plt%initialize(GNUPLOT_TERMINAL_PNG, "example_plot.png") ! Save to file directly 24 | call plt%set_title("Example Plot") 25 | 26 | xAxis => plt%get_x_axis() 27 | call xAxis%set_title("X Axis") 28 | 29 | yAxis => plt%get_y_axis() 30 | call yAxis%set_title("Y Axis") 31 | 32 | ! Put the legend in the upper left corner of the plot 33 | leg => plt%get_legend() 34 | call leg%set_is_visible(.true.) 35 | call leg%set_horizontal_position(LEGEND_LEFT) 36 | call leg%set_vertical_position(LEGEND_TOP) 37 | 38 | ! Set up line color and style properties to better distinguish each data set 39 | call d1%set_name("Data Set 1") 40 | call d1%set_line_color(CLR_BLUE) 41 | 42 | call d2%set_name("Data Set 2") 43 | call d2%set_line_color(CLR_GREEN) 44 | 45 | ! Add the data to the plot 46 | call plt%push(d1) 47 | call plt%push(d2) 48 | 49 | ! Draw the plot 50 | call plt%draw() 51 | end program -------------------------------------------------------------------------------- /examples/png_plot_example_2.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Local Variables & Parameters 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), dimension(npts) :: x, y1, y2 9 | type(plot_2d) :: plt 10 | class(terminal), pointer :: term 11 | type(plot_data_2d) :: d1, d2 12 | class(plot_axis), pointer :: xAxis, yAxis 13 | type(legend), pointer :: leg 14 | 15 | ! Build a data set to plot 16 | x = linspace(0.0d0, 10.0d0, npts) 17 | y1 = sin(x) * cos(x) 18 | y2 = sqrt(x) * sin(x) 19 | 20 | call d1%define_data(x, y1) 21 | call d2%define_data(x, y2) 22 | 23 | ! Set up the plot 24 | call plt%initialize(GNUPLOT_TERMINAL_PNG) ! Save to file directly 25 | call plt%set_title("Example Plot") 26 | 27 | xAxis => plt%get_x_axis() 28 | call xAxis%set_title("X Axis") 29 | 30 | yAxis => plt%get_y_axis() 31 | call yAxis%set_title("Y Axis") 32 | 33 | ! Put the legend outside the axes, and remove it's border 34 | leg => plt%get_legend() 35 | call leg%set_is_visible(.true.) 36 | call leg%set_draw_inside_axes(.false.) 37 | call leg%set_draw_border(.false.) 38 | 39 | ! Set up line color and style properties to better distinguish each data set 40 | call d1%set_name("Data Set 1") 41 | call d1%set_line_color(CLR_BLUE) 42 | 43 | call d2%set_name("Data Set 2") 44 | call d2%set_line_color(CLR_GREEN) 45 | 46 | ! Add the data to the plot 47 | call plt%push(d1) 48 | call plt%push(d2) 49 | 50 | ! Define the file to which the plot should be saved 51 | term => plt%get_terminal() 52 | select type (term) 53 | class is (png_terminal) 54 | call term%set_filename("example_plot_legend_out.png") 55 | end select 56 | 57 | ! Draw the plot 58 | call plt%draw() 59 | end program -------------------------------------------------------------------------------- /examples/polar_plot_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | 5 | ! Local Variables 6 | integer(int32), parameter :: npts = 1000 7 | real(real64), parameter :: pi = 2.0d0 * acos(0.0d0) 8 | real(real64) :: t(npts), x(npts) 9 | type(plot_polar) :: plt 10 | type(plot_data_2d) :: pd 11 | 12 | ! Create a function to plot 13 | t = linspace(-2.0d0 * pi, 2.0d0 * pi, npts) 14 | x = t * sin(t) 15 | 16 | ! Plot the function 17 | call plt%initialize() 18 | call plt%set_font_size(14) 19 | call plt%set_title("Polar Plot Example") 20 | call plt%set_autoscale(.false.) 21 | call plt%set_radial_limits([0.0d0, 6.0d0]) 22 | 23 | call pd%define_data(t, x) 24 | call pd%set_line_width(2.0) 25 | call plt%push(pd) 26 | call plt%draw() 27 | end program -------------------------------------------------------------------------------- /examples/save_to_file_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use fplot_core 3 | use iso_fortran_env 4 | implicit none 5 | 6 | ! Local Variables & Parameters 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), dimension(npts) :: x, y 9 | type(plot_2d) :: plt 10 | type(plot_data_2d) :: dataset 11 | class(plot_axis), pointer :: xAxis, yAxis 12 | 13 | ! Build a data set to plot 14 | x = linspace(0.0d0, 10.0d0, npts) 15 | y = exp(-0.5d0 * x) * sin(10.0d0 * x - 0.5d0) 16 | 17 | call dataset%define_data(x, y) 18 | 19 | ! Set up the plot 20 | call plt%initialize() 21 | call plt%set_title("Example Plot") 22 | 23 | xAxis => plt%get_x_axis() 24 | call xAxis%set_title("X Axis") 25 | 26 | yAxis => plt%get_y_axis() 27 | call yAxis%set_title("Y Axis") 28 | 29 | ! Add the data to the plot 30 | call plt%push(dataset) 31 | 32 | ! Save the plot to a file that can be opened by GNUPLOT at a later time 33 | call plt%save_file("example_gnuplot_file.plt") 34 | end program -------------------------------------------------------------------------------- /examples/secondary_y_axis_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use fplot_core 3 | use iso_fortran_env 4 | implicit none 5 | 6 | ! Local Variables 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), dimension(npts) :: x, y1, y2 9 | type(plot_2d) :: plt 10 | type(plot_data_2d) :: ds1, ds2 11 | class(plot_axis), pointer :: xAxis, yAxis, y2Axis 12 | 13 | ! Build a data set 14 | x = linspace(0.0d0, 10.0d0, npts) 15 | y1 = exp(-0.5d0 * x) * abs(sin(x)) 16 | y2 = cos(0.5d0 * x) * sin(10.0d0 * x) 17 | 18 | call ds1%define_data(x, y1) 19 | call ds1%set_name("f(x) = exp(-x / 2) * |sin(x)|") 20 | 21 | call ds2%define_data(x, y2) 22 | call ds2%set_name("f(x) = cos(x / 2) * sin(10 x)") 23 | 24 | ! Make the ds2 line green and dashed 25 | call ds2%set_line_color(CLR_GREEN) 26 | call ds2%set_line_style(LINE_DASHED) 27 | 28 | ! Draw ds2 against the secondary y axis 29 | call ds2%set_draw_against_y2(.true.) 30 | 31 | ! Ensure the plot knows it needs a secondary y axis 32 | call plt%set_use_y2_axis(.true.) 33 | 34 | ! Set up the plot 35 | call plt%initialize() 36 | call plt%set_title("Example Plot") 37 | 38 | xAxis => plt%get_x_axis() 39 | call xAxis%set_title("X Axis") 40 | 41 | yAxis => plt%get_y_axis() 42 | call yAxis%set_title("Y Axis") 43 | 44 | y2Axis => plt%get_y2_axis() 45 | call y2Axis%set_title("Secondary Y Axis") 46 | 47 | ! Add the data to the plot 48 | call plt%push(ds1) 49 | call plt%push(ds2) 50 | 51 | ! Draw 52 | call plt%draw() 53 | end program -------------------------------------------------------------------------------- /examples/square_axis_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Local Variables 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), parameter :: pi = 2.0d0 * acos(0.0d0) 9 | real(real64) :: t(npts), x(npts), y(npts) 10 | type(plot_2d) :: plt 11 | type(plot_data_2d) :: pd 12 | 13 | ! Generate the data 14 | t = linspace(0.0d0, 2.0d0 * pi, npts) 15 | x = cos(t) 16 | y = sin(t) 17 | 18 | ! Set up the plot 19 | call plt%initialize() 20 | call plt%set_font_size(14) 21 | call plt%set_title("Default Settings") 22 | 23 | call pd%define_data(x, y) 24 | call plt%push(pd) 25 | 26 | call plt%draw() 27 | 28 | ! Now show the effects of square axes 29 | call plt%set_axis_equal(.false.) 30 | call plt%set_square_axes(.true.) 31 | call plt%set_title("Square Axes") 32 | call plt%draw() 33 | end program -------------------------------------------------------------------------------- /examples/surface_plot_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use fplot_core 3 | use iso_fortran_env 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: m = 50 8 | integer(int32), parameter :: n = 50 9 | 10 | ! Local Variables 11 | real(real64), dimension(m, n, 2), target :: xy 12 | real(real64), pointer, dimension(:,:) :: x, y 13 | real(real64), dimension(m, n) :: z 14 | type(surface_plot) :: plt 15 | type(surface_plot_data) :: d1 16 | class(plot_axis), pointer :: xAxis, yAxis, zAxis 17 | type(rainbow_colormap) :: map 18 | 19 | ! Define the data 20 | xy = meshgrid(linspace(-5.0d0, 5.0d0, n), linspace(-5.0d0, 5.0d0, m)) 21 | x => xy(:,:,1) 22 | y => xy(:,:,2) 23 | 24 | ! Initialize the plot 25 | call plt%initialize() 26 | call plt%set_colormap(map) 27 | 28 | ! Establish lighting 29 | call plt%set_use_lighting(.true.) 30 | 31 | ! Set the orientation of the plot 32 | call plt%set_elevation(20.0d0) 33 | call plt%set_azimuth(30.0d0) 34 | 35 | ! Define titles 36 | call plt%set_title("Example Plot") 37 | 38 | xAxis => plt%get_x_axis() 39 | call xAxis%set_title("X Axis") 40 | 41 | yAxis => plt%get_y_axis() 42 | call yAxis%set_title("Y Axis") 43 | 44 | zAxis => plt%get_z_axis() 45 | call zAxis%set_title("Z Axis") 46 | 47 | ! Define the function to plot 48 | z = sqrt(x**2 + y**2) * sin(x**2 + y**2) 49 | call d1%define_data(x, y, z) 50 | call plt%push(d1) 51 | 52 | ! Draw the plot 53 | call plt%draw() 54 | end program -------------------------------------------------------------------------------- /examples/surface_plot_example_2.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use, intrinsic :: iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: m = 50 8 | integer(int32), parameter :: n = 50 9 | real(real64), parameter :: xMax = 5.0d0 10 | real(real64), parameter :: xMin = -5.0d0 11 | real(real64), parameter :: yMax = 5.0d0 12 | real(real64), parameter :: yMin = -5.0d0 13 | 14 | ! Local Variables 15 | real(real64), dimension(n) :: xdata 16 | real(real64), dimension(m) :: ydata 17 | real(real64), dimension(:,:), pointer :: x, y 18 | real(real64), dimension(m, n, 2), target :: xy 19 | real(real64), dimension(m, n) :: z 20 | type(surface_plot) :: plt 21 | type(surface_plot_data) :: d1 22 | type(rainbow_colormap) :: map 23 | class(plot_axis), pointer :: xAxis, yAxis, zAxis 24 | 25 | ! Define the data 26 | xdata = linspace(xMin, xMax, n) 27 | ydata = linspace(yMin, yMax, m) 28 | xy = meshgrid(xdata, ydata) 29 | x => xy(:,:,1) 30 | y => xy(:,:,2) 31 | 32 | ! Define the function to plot 33 | z = sin(sqrt(x**2 + y**2)) 34 | 35 | ! Define colormap settings 36 | call map%set_show_tics(.false.) 37 | 38 | ! Create the plot 39 | call plt%initialize() 40 | call plt%set_colormap(map) 41 | 42 | ! Define titles 43 | call plt%set_title("Example Plot") 44 | 45 | xAxis => plt%get_x_axis() 46 | call xAxis%set_title("X Axis") 47 | 48 | yAxis => plt%get_y_axis() 49 | call yAxis%set_title("Y Axis") 50 | 51 | zAxis => plt%get_z_axis() 52 | call zAxis%set_title("Z Axis") 53 | 54 | ! Define the data set 55 | call d1%define_data(x, y, z) 56 | call plt%push(d1) 57 | 58 | ! Let GNUPLOT draw the plot 59 | call plt%draw() 60 | end program -------------------------------------------------------------------------------- /examples/triangle_mesh_surface_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Variables 7 | integer(int32), parameter :: npts = 15 8 | real(real64), allocatable :: xc(:,:), yc(:,:), x(:), y(:), z(:), xy(:,:,:) 9 | real(real64) :: xi, yi, zi 10 | type(delaunay_tri_surface) :: tri 11 | type(tri_surface_plot_data) :: ds 12 | type(plot_data_3d) :: di 13 | type(surface_plot) :: plt 14 | class(plot_axis), pointer :: xAxis, yAxis, zAxis 15 | integer(int32) :: i 16 | 17 | ! Initialization 18 | xy = meshgrid(linspace(-5.0d0, 5.0d0, npts), linspace(-5.0d0, 5.0d0, npts)) 19 | xc = xy(:,:,1) 20 | yc = xy(:,:,2) 21 | x = reshape(xc, [npts * npts]) 22 | y = reshape(yc, [npts * npts]) 23 | z = sin(x) + sin(y) 24 | 25 | ! Generate the triangulation 26 | call tri%create(x, y) 27 | call tri%define_function_values(z) 28 | 29 | ! Interpolate using the triangulation 30 | xi = 2.0d0 31 | yi = 2.0d0 32 | zi = tri%evaluate(xi, yi) 33 | 34 | ! Print the interpolated values 35 | print '(A)', "Interpolated Value:" 36 | print '(AF0.3AF0.3AF0.3)', achar(9), xi, achar(9), yi, achar(9), zi 37 | 38 | print '(A)', "Actual Values:" 39 | print '(AF0.3AF0.3AF0.3)', achar(9), xi, achar(9), yi, achar(9), & 40 | sin(xi) + sin(yi) 41 | 42 | ! Generate the plot 43 | call plt%initialize() 44 | call plt%set_font_size(14) 45 | 46 | xAxis => plt%get_x_axis() 47 | yAxis => plt%get_y_axis() 48 | zAxis => plt%get_z_axis() 49 | 50 | call xAxis%set_title("x") 51 | call yAxis%set_title("y") 52 | call zAxis%set_title("f(x,y)") 53 | 54 | call ds%define_data(tri) 55 | call ds%set_use_wireframe(.true.) 56 | 57 | call di%define_data([xi], [yi], [zi]) 58 | call di%set_draw_line(.false.) 59 | call di%set_line_width(2.0) 60 | call di%set_draw_markers(.true.) 61 | call di%set_marker_style(MARKER_FILLED_CIRCLE) 62 | call di%set_marker_scaling(3.0) 63 | call di%set_line_color(CLR_RED) 64 | 65 | call plt%push(ds) 66 | call plt%push(di) 67 | call plt%draw() 68 | end program -------------------------------------------------------------------------------- /examples/triangulation_2d_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), parameter :: pi = 2.0d0 * acos(0.0d0) 9 | 10 | ! Local Variables 11 | type(delaunay_tri_2d) :: tri 12 | real(real64) :: x(npts), y(npts), theta(npts), radius(npts) 13 | type(plot_2d) :: plt 14 | type(plot_data_tri_2d) :: ds 15 | 16 | ! Initialization 17 | call random_number(theta) 18 | theta = 2.0d0 * pi * theta 19 | 20 | call random_number(radius) 21 | radius = radius + 0.5d0 22 | 23 | x = radius * cos(theta) 24 | y = radius * sin(theta) 25 | 26 | ! Create a 2D triangulation from the data 27 | call tri%create(x, y) 28 | 29 | ! Display the number of points and elements 30 | print '(AI0AI0A)', "The triangulation consists of ", & 31 | tri%get_point_count(), " points, and ", tri%get_triangle_count(), & 32 | " triangles." 33 | 34 | ! Plot the triangulation 35 | call plt%initialize() 36 | call plt%set_font_size(14) 37 | 38 | call ds%define_data(tri) 39 | call plt%push(ds) 40 | 41 | call plt%draw() 42 | end program 43 | -------------------------------------------------------------------------------- /examples/triangulation_2d_location_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use fplot_core 3 | use iso_fortran_env 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: npts = 1000 8 | real(real64), parameter :: pi = 2.0d0 * acos(0.0d0) 9 | real(real64), parameter :: xpt = 0.75d0 10 | real(real64), parameter :: ypt = 0.75d0 11 | 12 | ! Local Variables 13 | type(delaunay_tri_2d) :: tri 14 | real(real64) :: x(npts), y(npts), theta(npts), radius(npts), & 15 | xtri(3), ytri(3) 16 | integer(int32) :: ind, n1, n2, n3 17 | integer(int32), allocatable, dimension(:,:) :: indices 18 | type(plot_2d) :: plt 19 | type(plot_data_tri_2d) :: ds 20 | type(plot_data_2d) :: dtri, dpt 21 | 22 | ! Initialization 23 | call random_number(theta) 24 | theta = 2.0d0 * pi * theta 25 | 26 | call random_number(radius) 27 | radius = radius + 0.5d0 28 | 29 | x = radius * cos(theta) 30 | y = radius * sin(theta) 31 | 32 | ! Create a 2D triangulation from the data 33 | call tri%create(x, y) 34 | 35 | ! Find the index of the triangle containing (xpt, ypt) 36 | ind = tri%find_triangle(xpt, ypt) 37 | if (ind == -1) then 38 | print '(A)', "No triangle was found that included the specified point." 39 | end if 40 | 41 | ! Get the vertices of this triangle 42 | indices = tri%get_indices() 43 | n1 = indices(ind, 1) 44 | n2 = indices(ind, 2) 45 | n3 = indices(ind, 3) 46 | xtri = [x(n1), x(n2), x(n3)] 47 | ytri = [y(n1), y(n2), y(n3)] 48 | 49 | ! Plot the triangulation, the point of interest, and highlight the triangle 50 | call plt%initialize() 51 | call plt%set_font_size(14) 52 | 53 | call ds%define_data(tri) 54 | call plt%push(ds) 55 | 56 | call dtri%define_data(xtri, ytri) 57 | call dtri%set_draw_line(.false.) 58 | call dtri%set_draw_markers(.true.) 59 | call dtri%set_marker_style(MARKER_FILLED_CIRCLE) 60 | call dtri%set_marker_scaling(1.2) 61 | call dtri%set_line_color(CLR_LIME) 62 | call plt%push(dtri) 63 | 64 | call dpt%define_data([xpt], [ypt]) 65 | call dpt%set_draw_line(.false.) 66 | call dpt%set_draw_markers(.true.) 67 | call dpt%set_marker_style(MARKER_X) 68 | call dpt%set_marker_scaling(3.0) 69 | call dpt%set_line_width(2.0) 70 | call plt%push(dpt) 71 | 72 | call plt%draw() 73 | end program 74 | -------------------------------------------------------------------------------- /examples/variable_point_size_2d_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Variables 7 | integer(int32), parameter :: npts = 10 8 | real(real64) :: x(npts), y(npts) 9 | type(plot_2d) :: plt 10 | type(plot_data_2d) :: pd 11 | type(parula_colormap) :: map 12 | 13 | ! Create the data to plot 14 | x = linspace(0.0d0, 5.0d0, npts) 15 | call random_number(y) 16 | 17 | ! Plot the results 18 | call plt%initialize() 19 | call plt%set_colormap(map) 20 | 21 | call pd%define_data(x, y, ps = 3.0d0 * y, c = y) 22 | call pd%set_draw_markers(.true.) 23 | call pd%set_draw_line(.false.) 24 | call plt%push(pd) 25 | 26 | call plt%draw() 27 | end program -------------------------------------------------------------------------------- /examples/variable_point_size_3d_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Variables 7 | integer(int32), parameter :: npts = 10 8 | real(real64) :: x(npts), y(npts), z(npts) 9 | type(plot_3d) :: plt 10 | type(plot_data_3d) :: pd 11 | type(parula_colormap) :: map 12 | 13 | ! Create the data to plot 14 | x = linspace(0.0d0, 5.0d0, npts) 15 | y = linspace(0.0d0, 5.0d0, npts) 16 | call random_number(z) 17 | 18 | ! Plot the results 19 | call plt%initialize() 20 | call plt%set_colormap(map) 21 | 22 | call pd%define_data(x, z, z, ps = 5.0d0 * z, c = z) 23 | call pd%set_draw_markers(.true.) 24 | call pd%set_draw_line(.false.) 25 | call plt%push(pd) 26 | 27 | call plt%draw() 28 | end program -------------------------------------------------------------------------------- /examples/vector_plot_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Local Variables 7 | type(plot_2d) :: plt 8 | type(vector_field_plot_data) :: ds1 9 | class(plot_axis), pointer :: xAxis, yAxis 10 | real(real64), allocatable, dimension(:,:,:) :: pts 11 | real(real64), allocatable, dimension(:,:) :: dx, dy 12 | real(real64) :: dxdt(2) 13 | integer(int32) :: i, j 14 | 15 | ! Create a grid of points defining the vector locations 16 | pts = meshgrid( & 17 | linspace(-2.0d0, 2.0d0, 20), & 18 | linspace(-5.0d0, 5.0d0, 20)) 19 | 20 | ! Compute the values of each derivative 21 | allocate(dx(size(pts, 1), size(pts, 2))) 22 | allocate(dy(size(pts, 1), size(pts, 2))) 23 | do j = 1, size(pts, 2) 24 | do i = 1, size(pts, 1) 25 | call eqn([pts(i,j,1), pts(i,j,2)], dxdt) 26 | dx(i,j) = dxdt(1) 27 | dy(i,j) = dxdt(2) 28 | end do 29 | end do 30 | 31 | ! Define arrow properties 32 | call ds1%set_arrow_size(0.1d0) ! 1.0 by default 33 | call ds1%set_fill_arrow(.true.) ! .false. by default 34 | 35 | ! Create the plot 36 | call plt%initialize() 37 | call plt%set_font_size(14) 38 | xAxis => plt%get_x_axis() 39 | yAxis => plt%get_y_axis() 40 | 41 | ! Define axis labels 42 | call xAxis%set_title("x(t)") 43 | call yAxis%set_title("dx/dt") 44 | 45 | ! Set plot style information 46 | call xAxis%set_zero_axis(.true.) 47 | call yAxis%set_zero_axis(.true.) 48 | call plt%set_draw_border(.false.) 49 | call plt%set_show_gridlines(.false.) 50 | 51 | ! Add the data to the plot 52 | call ds1%define_data(pts(:,:,1), pts(:,:,2), dx, dy) 53 | call plt%push(ds1) 54 | 55 | call plt%draw() 56 | contains 57 | ! Van der Pol Equation 58 | ! x" - mu * (1 - x^2) * x' + x = 0 59 | subroutine eqn(x, dxdt) 60 | real(real64), intent(in) :: x(2) 61 | real(real64), intent(out) :: dxdt(2) 62 | 63 | real(real64), parameter :: mu = 2.0d0 64 | 65 | dxdt(1) = x(2) 66 | dxdt(2) = mu * (1.0d0 - x(1)**2) * x(2) - x(1) 67 | end subroutine 68 | end program -------------------------------------------------------------------------------- /examples/wireframe_surface_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use, intrinsic :: iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: m = 50 8 | integer(int32), parameter :: n = 50 9 | real(real64), parameter :: xMax = 5.0d0 10 | real(real64), parameter :: xMin = -5.0d0 11 | real(real64), parameter :: yMax = 5.0d0 12 | real(real64), parameter :: yMin = -5.0d0 13 | 14 | ! Local Variables 15 | real(real64), dimension(n) :: xdata 16 | real(real64), dimension(m) :: ydata 17 | real(real64), dimension(:,:), pointer :: x, y 18 | real(real64), dimension(m, n, 2), target :: xy 19 | real(real64), dimension(m, n) :: z 20 | type(surface_plot) :: plt 21 | type(surface_plot_data) :: d1 22 | ! type(rainbow_colormap) :: map 23 | class(plot_axis), pointer :: xAxis, yAxis, zAxis 24 | 25 | ! Define the data 26 | xdata = linspace(xMin, xMax, n) 27 | ydata = linspace(yMin, yMax, m) 28 | xy = meshgrid(xdata, ydata) 29 | x => xy(:,:,1) 30 | y => xy(:,:,2) 31 | 32 | ! Define the function to plot 33 | z = sin(sqrt(x**2 + y**2)) 34 | 35 | ! Create the plot 36 | call plt%initialize() 37 | call plt%set_show_hidden(.true.) 38 | call d1%set_use_wireframe(.true.) 39 | ! call plt%set_colormap(map) 40 | 41 | ! Set up lighting 42 | call plt%set_use_lighting(.true.) 43 | call plt%set_light_intensity(0.7) 44 | call plt%set_specular_intensity(0.7) 45 | 46 | ! Define titles 47 | call plt%set_title("Example Plot") 48 | 49 | xAxis => plt%get_x_axis() 50 | call xAxis%set_title("X Axis") 51 | 52 | yAxis => plt%get_y_axis() 53 | call yAxis%set_title("Y Axis") 54 | 55 | zAxis => plt%get_z_axis() 56 | call zAxis%set_title("Z Axis") 57 | 58 | ! Define the data set 59 | call d1%define_data(x, y, z) 60 | call d1%set_name("sin(sqrt(x**2 + y**2))") 61 | call plt%push(d1) 62 | 63 | ! Let GNUPLOT draw the plot 64 | call plt%draw() 65 | end program 66 | -------------------------------------------------------------------------------- /examples/zero_axis_example.f90: -------------------------------------------------------------------------------- 1 | program example 2 | use, intrinsic :: iso_fortran_env 3 | use fplot_core 4 | implicit none 5 | 6 | ! Parameters 7 | integer(int32), parameter :: n = 1000 8 | 9 | ! Local Variables 10 | real(real64), dimension(n) :: x, y1, y2 11 | type(plot_2d) :: plt 12 | type(plot_data_2d) :: d1, d2 13 | class(plot_axis), pointer :: xAxis, yAxis 14 | type(legend), pointer :: lgnd 15 | 16 | ! Initialize the plot object 17 | call plt%initialize() 18 | 19 | ! Set plot properties 20 | call plt%set_draw_border(.false.) 21 | call plt%set_show_gridlines(.false.) 22 | 23 | ! Define the legend location 24 | lgnd => plt%get_legend() 25 | call lgnd%set_is_visible(.true.) 26 | call lgnd%set_draw_inside_axes(.false.) 27 | 28 | ! Define titles 29 | call plt%set_title("2D Example Plot 2") 30 | 31 | xAxis => plt%get_x_axis() 32 | call xAxis%set_title("X Axis") 33 | call xAxis%set_zero_axis(.true.) 34 | call xAxis%set_zero_axis_line_width(1.0) 35 | 36 | yAxis => plt%get_y_axis() 37 | call yAxis%set_title("Y Axis") 38 | 39 | ! Define the data, and then add it to the plot 40 | x = linspace(0.0d0, 10.d0, n) 41 | y1 = sin(5.0d0 * x) 42 | y2 = 2.0d0 * cos(2.0d0 * x) 43 | 44 | call d1%define_data(x, y1) 45 | call d2%define_data(x, y2) 46 | 47 | ! Define properties for each data set 48 | call d1%set_name("Data Set 1") 49 | call d1%set_line_width(1.0) 50 | 51 | call d2%set_name("Data Set 2") 52 | call d2%set_line_style(LINE_DASHED) 53 | call d2%set_line_width(2.0) 54 | 55 | ! Add the data sets to the plot 56 | call plt%push(d1) 57 | call plt%push(d2) 58 | 59 | ! Let GNUPLOT draw the plot 60 | call plt%draw() 61 | end program -------------------------------------------------------------------------------- /fpm.toml: -------------------------------------------------------------------------------- 1 | name = "fplot" 2 | version = "1.8.0" 3 | license = "GPL-3.0" 4 | author = "Jason Christopherson" 5 | maintainer = "Jason Christopherson" 6 | copyright = "Copyright 2017-2025, Jason Christopherson" 7 | description = "A Fortran library providing a convenient interface for plotting with Gnuplot." 8 | homepage = "https://github.com/jchristopherson/fplot" 9 | 10 | [library] 11 | source-dir = "src" 12 | 13 | [dependencies] 14 | ferror = { git = "https://github.com/jchristopherson/ferror" } 15 | collections = { git = "https://github.com/jchristopherson/collections" } 16 | fstring = { git = "https://github.com/jchristopherson/fstring" } 17 | geompack = { git = "https://github.com/jchristopherson/geompack" } 18 | forcolormap = { git = "https://github.com/vmagnin/forcolormap" } 19 | 20 | [dev-dependencies] 21 | fortran_test_helper = { git = "https://github.com/jchristopherson/fortran_test_helper" } 22 | 23 | [install] 24 | library = true 25 | 26 | [build] 27 | auto-executables = false 28 | auto-examples = false 29 | auto-tests = false 30 | 31 | [[test]] 32 | name = "fplot_test" 33 | source-dir = "test" 34 | main = "fplot_test.f90" 35 | -------------------------------------------------------------------------------- /images/custom_colormap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/custom_colormap.png -------------------------------------------------------------------------------- /images/default_2d_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/default_2d_example.png -------------------------------------------------------------------------------- /images/example_2d_log_scaling_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_2d_log_scaling_1.png -------------------------------------------------------------------------------- /images/example_2d_plot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_2d_plot_1.png -------------------------------------------------------------------------------- /images/example_2d_plot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_2d_plot_2.png -------------------------------------------------------------------------------- /images/example_data_depend_color_2d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_data_depend_color_2d.png -------------------------------------------------------------------------------- /images/example_data_depend_color_3d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_data_depend_color_3d.png -------------------------------------------------------------------------------- /images/example_delaunay_2d_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_delaunay_2d_1.png -------------------------------------------------------------------------------- /images/example_delaunay_2d_2a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_delaunay_2d_2a.png -------------------------------------------------------------------------------- /images/example_delaunay_2d_2b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_delaunay_2d_2b.png -------------------------------------------------------------------------------- /images/example_label_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_label_plot.png -------------------------------------------------------------------------------- /images/example_multiplot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_multiplot_1.png -------------------------------------------------------------------------------- /images/example_multiplot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_multiplot_2.png -------------------------------------------------------------------------------- /images/example_multiplot_log_scaled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_multiplot_log_scaled.png -------------------------------------------------------------------------------- /images/example_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_plot.png -------------------------------------------------------------------------------- /images/example_plot_2d_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_plot_2d_1.png -------------------------------------------------------------------------------- /images/example_plot_2d_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_plot_2d_2.png -------------------------------------------------------------------------------- /images/example_plot_2d_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_plot_2d_3.png -------------------------------------------------------------------------------- /images/example_plot_3d_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_plot_3d_1.png -------------------------------------------------------------------------------- /images/example_plot_3d_offset_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_plot_3d_offset_1.png -------------------------------------------------------------------------------- /images/example_plot_from_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_plot_from_file.png -------------------------------------------------------------------------------- /images/example_plot_legend_out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_plot_legend_out.png -------------------------------------------------------------------------------- /images/example_plot_with_label_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_plot_with_label_1.png -------------------------------------------------------------------------------- /images/example_plot_y2_axis_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_plot_y2_axis_1.png -------------------------------------------------------------------------------- /images/example_surf_plot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surf_plot_1.png -------------------------------------------------------------------------------- /images/example_surface_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot.png -------------------------------------------------------------------------------- /images/example_surface_plot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_2.png -------------------------------------------------------------------------------- /images/example_surface_plot_cool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_cool.png -------------------------------------------------------------------------------- /images/example_surface_plot_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_default.png -------------------------------------------------------------------------------- /images/example_surface_plot_earth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_earth.png -------------------------------------------------------------------------------- /images/example_surface_plot_grey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_grey.png -------------------------------------------------------------------------------- /images/example_surface_plot_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_horizontal.png -------------------------------------------------------------------------------- /images/example_surface_plot_hot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_hot.png -------------------------------------------------------------------------------- /images/example_surface_plot_lighting_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_lighting_1.png -------------------------------------------------------------------------------- /images/example_surface_plot_lighting_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_lighting_2.png -------------------------------------------------------------------------------- /images/example_surface_plot_no_border.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_no_border.png -------------------------------------------------------------------------------- /images/example_surface_plot_no_tics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_no_tics.png -------------------------------------------------------------------------------- /images/example_surface_plot_parula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_parula.png -------------------------------------------------------------------------------- /images/example_surface_plot_with_contour_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_surface_plot_with_contour_1.png -------------------------------------------------------------------------------- /images/example_tri_surf_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_tri_surf_1.png -------------------------------------------------------------------------------- /images/example_wireframe_surface_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_wireframe_surface_plot.png -------------------------------------------------------------------------------- /images/example_x_errorbars_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_x_errorbars_1.png -------------------------------------------------------------------------------- /images/example_xy_errorbars_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_xy_errorbars_1.png -------------------------------------------------------------------------------- /images/example_xy_errorbox_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_xy_errorbox_1.png -------------------------------------------------------------------------------- /images/example_y_errorbars_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/example_y_errorbars_1.png -------------------------------------------------------------------------------- /images/filled_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/filled_example_1.png -------------------------------------------------------------------------------- /images/filled_example_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/filled_example_2.png -------------------------------------------------------------------------------- /images/histogram_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/histogram_example_1.png -------------------------------------------------------------------------------- /images/polar_example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/polar_example_1.png -------------------------------------------------------------------------------- /images/polar_example_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/polar_example_2.png -------------------------------------------------------------------------------- /images/square_2d_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/square_2d_example.png -------------------------------------------------------------------------------- /images/surface_example_w_cb_label.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/surface_example_w_cb_label.png -------------------------------------------------------------------------------- /images/surface_plot_hidden_lines_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/surface_plot_hidden_lines_1.png -------------------------------------------------------------------------------- /images/vector_plot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/vector_plot_1.png -------------------------------------------------------------------------------- /images/vector_plot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jchristopherson/fplot/eeb248b26c3f9d691100f2cb25846770933dceb4/images/vector_plot_2.png -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project('fplot', 'fortran') 2 | 3 | fcore_proj = subproject('fcore') 4 | fcore_dep = fcore_proj.get_variable('fcore_dep') 5 | 6 | ferror_proj = subproject('ferror') 7 | ferror_dep = ferror_proj.get_variable('ferror_dep') 8 | 9 | subdir('src') 10 | 11 | fplot_lib = static_library('fplot', sources, 12 | dependencies: [fcore_dep, ferror_dep]) 13 | 14 | fplot_dep = declare_dependency(link_with: fplot_lib) 15 | 16 | subdir('examples') 17 | -------------------------------------------------------------------------------- /packages.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fplot-jchristopherson", 3 | "description": "A Fortran library providing a convenient interface for plotting with Gnuplot.", 4 | "author": "Jason Christopherson", 5 | "version": "1.3.2" 6 | } 7 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Locate the source directory 2 | set(dir ${CMAKE_CURRENT_SOURCE_DIR}) 3 | 4 | # Define the source files 5 | set(FPLOT_SOURCES 6 | ${dir}/fplot_core.f90 7 | ${dir}/fplot_core_routines.f90 8 | ${dir}/fplot_colors.f90 9 | ${dir}/fplot_terminal.f90 10 | ${dir}/fplot_windows_terminal.f90 11 | ${dir}/fplot_qt_terminal.f90 12 | ${dir}/fplot_wxt_terminal.f90 13 | ${dir}/fplot_png_terminal.f90 14 | ${dir}/fplot_latex_terminal.f90 15 | ${dir}/fplot_plot_data.f90 16 | ${dir}/fplot_plot_axis.f90 17 | ${dir}/fplot_legend.f90 18 | ${dir}/fplot_plot.f90 19 | ${dir}/fplot_colormap.f90 20 | ${dir}/fplot_simplify.f90 21 | ${dir}/fplot_plot_2d.f90 22 | ${dir}/fplot_plot_3d.f90 23 | ${dir}/fplot_surface_plot.f90 24 | ${dir}/fplot_label.f90 25 | ${dir}/fplot_multiplot.f90 26 | ${dir}/fplot_plot_data_error_bars.f90 27 | ${dir}/fplot_plot_data_bar.f90 28 | ${dir}/fplot_plot_data_histogram.f90 29 | ${dir}/fplot_plot_bar.f90 30 | ${dir}/fplot_plot_data_tri_2d.f90 31 | ${dir}/fplot_delaunay_tri_surface.f90 32 | ${dir}/fplot_tri_surface_plot_data.f90 33 | ${dir}/fplot_vector_field_plot_data.f90 34 | ${dir}/fplot_plot_polar.f90 35 | ${dir}/fplot_filled_plot_data.f90 36 | ${dir}/fplot_triangulations_delaunay_2d.f90 37 | ${dir}/fplot_arrow.f90 38 | ${dir}/fplot_errors.f90 39 | ${dir}/fplot_constants.f90 40 | ${dir}/fplot_plot_object.f90 41 | ${dir}/fplot_plot_data_2d.f90 42 | ${dir}/fplot_plot_data_3d.f90 43 | ${dir}/fplot_surface_plot_data.f90 44 | ${dir}/fplot_stats_plots.f90 45 | ) 46 | set(FPLOT_SOURCES ${FPLOT_SOURCES} PARENT_SCOPE) 47 | -------------------------------------------------------------------------------- /src/fplot_colors.f90: -------------------------------------------------------------------------------- 1 | ! fplot_colors.f90 2 | 3 | module fplot_colors 4 | use iso_fortran_env 5 | implicit none 6 | private 7 | public :: color 8 | public :: operator(==) 9 | public :: operator(/=) 10 | public :: CLR_BLACK 11 | public :: CLR_WHITE 12 | public :: CLR_RED 13 | public :: CLR_LIME 14 | public :: CLR_BLUE 15 | public :: CLR_YELLOW 16 | public :: CLR_CYAN 17 | public :: CLR_MAGENTA 18 | public :: CLR_SILVER 19 | public :: CLR_GRAY 20 | public :: CLR_MAROON 21 | public :: CLR_OLIVE 22 | public :: CLR_GREEN 23 | public :: CLR_PURPLE 24 | public :: CLR_TEAL 25 | public :: CLR_NAVY 26 | public :: CLR_ORANGE 27 | public :: color_list 28 | 29 | type color 30 | !! Describes an RGB color. 31 | integer(int32), public :: red = 0 32 | !! The red component of the color (must be between 0 and 255). 33 | integer(int32), public :: green = 0 34 | !! The green component of the color (must be between 0 and 255). 35 | integer(int32), public :: blue = 255 36 | !! The blue component of the color (must be between 0 and 255). 37 | integer(int32), public :: alpha = 0 38 | !! The alpha component of the color (must be between 0 and 255). 39 | !! Notice, 0 is fully opaque and 255 is fully transparent. 40 | contains 41 | procedure, public, pass :: to_hex_string => clr_to_hex_string 42 | procedure, public, pass :: copy_from => clr_copy_from 43 | end type 44 | 45 | interface operator(==) 46 | module procedure :: clr_equals 47 | end interface 48 | 49 | interface operator(/=) 50 | module procedure :: clr_not_equals 51 | end interface 52 | 53 | type(color), parameter :: CLR_BLACK = color(0, 0, 0, 0) 54 | !! Black. 55 | type(color), parameter :: CLR_WHITE = color(255, 255, 255, 0) 56 | !! White. 57 | type(color), parameter :: CLR_RED = color(255, 0, 0, 0) 58 | !! Red. 59 | type(color), parameter :: CLR_LIME = color(0, 255, 0, 0) 60 | !! Lime. 61 | type(color), parameter :: CLR_BLUE = color(0, 0, 255, 0) 62 | !! Blue. 63 | type(color), parameter :: CLR_YELLOW = color(255, 255, 0, 0) 64 | !! Yellow. 65 | type(color), parameter :: CLR_CYAN = color(0, 255, 255, 0) 66 | !! Cyan. 67 | type(color), parameter :: CLR_MAGENTA = color(255, 0, 255, 0) 68 | !! Magenta. 69 | type(color), parameter :: CLR_SILVER = color(192, 192, 192, 0) 70 | !! Silver. 71 | type(color), parameter :: CLR_GRAY = color(128, 128, 128, 0) 72 | !! Gray. 73 | type(color), parameter :: CLR_MAROON = color(128, 0, 0, 0) 74 | !! Maroon. 75 | type(color), parameter :: CLR_OLIVE = color(128, 128, 0, 0) 76 | !! Olive. 77 | type(color), parameter :: CLR_GREEN = color(0, 128, 0, 0) 78 | !! Green. 79 | type(color), parameter :: CLR_PURPLE = color(128, 0, 128, 0) 80 | !! Purple. 81 | type(color), parameter :: CLR_TEAL = color(0, 128, 128, 0) 82 | !! Teal. 83 | type(color), parameter :: CLR_NAVY = color(0, 0, 128, 0) 84 | !! Navy. 85 | type(color), parameter :: CLR_ORANGE = color(255, 165, 0, 0) 86 | !! Orange. 87 | 88 | ! A list of colors that can be cycled through by plotting code 89 | type(color), parameter, dimension(7) :: color_list = [ & 90 | color(0, int(0.447 * 255), int(0.741 * 255), 0), & 91 | color(int(0.85 * 255), int(0.325 * 255), int(0.098 * 255), 0), & 92 | color(int(0.929 * 255), int(0.694 * 255), int(0.125 * 255), 0), & 93 | color(int(0.494 * 255), int(0.184 * 255), int(0.556 * 255), 0), & 94 | color(int(0.466 * 255), int(0.674 * 255), int(0.188 * 255), 0), & 95 | color(int(0.301 * 255), int(0.745 * 255), int(0.933 * 255), 0), & 96 | color(int(0.635 * 255), int(0.078 * 255), int(0.184 * 255), 0)] 97 | 98 | contains 99 | ! ------------------------------------------------------------------------------ 100 | pure function clr_to_hex_string(this) result(txt) 101 | !! Returns the color in hexadecimal format. 102 | class(color), intent(in) :: this 103 | !! The color object. 104 | character(8) :: txt 105 | !! A string containing the hexadecimal equivalent. 106 | 107 | ! Local Variables 108 | integer(int32) :: r, g, b, a, clr 109 | 110 | ! Clip each color if necessary 111 | if (this%red < 0) then 112 | r = 0 113 | else if (this%red > 255) then 114 | r = 255 115 | else 116 | r = this%red 117 | end if 118 | 119 | if (this%green < 0) then 120 | g = 0 121 | else if (this%green > 255) then 122 | g = 255 123 | else 124 | g = this%green 125 | end if 126 | 127 | if (this%blue < 0) then 128 | b = 0 129 | else if (this%blue > 255) then 130 | b = 255 131 | else 132 | b = this%blue 133 | end if 134 | 135 | if (this%alpha < 0) then 136 | a = 0 137 | else if (this%alpha > 255) then 138 | a = 255 139 | else 140 | a = this%alpha 141 | end if 142 | 143 | ! Build the color information 144 | clr = ishft(a, 24) + ishft(r, 16) + ishft(g, 8) + b 145 | 146 | ! Convert the integer to a hexadecimal string 147 | write(txt, '(Z8.8)') clr 148 | end function 149 | 150 | ! ------------------------------------------------------------------------------ 151 | subroutine clr_copy_from(this, clr) 152 | !! Copies another color to this color. 153 | class(color), intent(inout) :: this 154 | !! The color object. 155 | class(color), intent(in) :: clr 156 | !! The color to copy. 157 | 158 | this%red = clr%red 159 | this%green = clr%green 160 | this%blue = clr%blue 161 | end subroutine 162 | 163 | ! ****************************************************************************** 164 | ! ADDED: JAN. 09, 2024 - JAC 165 | ! ------------------------------------------------------------------------------ 166 | ! pure subroutine clr_assign(x, y) 167 | ! type(color), intent(out) :: x 168 | ! class(color), intent(in) :: y 169 | ! call x%copy_from(y) 170 | ! end subroutine 171 | 172 | ! ------------------------------------------------------------------------------ 173 | pure function clr_equals(x, y) result(rst) 174 | type(color), intent(in) :: x, y 175 | logical :: rst 176 | rst = .true. 177 | if (x%red /= y%red .or. & 178 | x%green /= y%green .or. & 179 | x%blue /= y%blue & 180 | ) then 181 | rst = .false. 182 | end if 183 | end function 184 | 185 | ! ------------------------------------------------------------------------------ 186 | pure function clr_not_equals(x, y) result(rst) 187 | type(color), intent(in) :: x, y 188 | logical :: rst 189 | rst = .not.clr_equals(x, y) 190 | end function 191 | 192 | ! ------------------------------------------------------------------------------ 193 | end module -------------------------------------------------------------------------------- /src/fplot_core_routines.f90: -------------------------------------------------------------------------------- 1 | ! fplot_core_routines.f90 2 | 3 | module fplot_core_routines 4 | use iso_fortran_env 5 | implicit none 6 | private 7 | public :: linspace 8 | public :: logspace 9 | public :: meshgrid 10 | 11 | contains 12 | ! ------------------------------------------------------------------------------ 13 | pure function linspace(start, finish, npts) result(x) 14 | !! Constructs a linearly spaced array. 15 | real(real64), intent(in) :: start 16 | !! The first value in the array. 17 | real(real64), intent(in) :: finish 18 | !! The last value in the array. 19 | integer(int32), intent(in) :: npts 20 | !! The number of values in the array. 21 | real(real64), allocatable, dimension(:) :: x 22 | !! The resulting array. 23 | 24 | ! Local Variables 25 | integer(int32) :: i 26 | real(real64) :: dx 27 | 28 | ! Process 29 | allocate(x(npts)) 30 | dx = (finish - start) / (npts - 1.0d0) 31 | x(1) = start 32 | do i = 2, npts 33 | x(i) = x(i-1) + dx 34 | end do 35 | end function 36 | 37 | ! ------------------------------------------------------------------------------ 38 | pure function logspace(start, finish, npts) result(x) 39 | !! Construcst a logarithmically spaced array. 40 | real(real64), intent(in) :: start 41 | !! The exponent of the first value in the array. 42 | real(real64), intent(in) :: finish 43 | !! The exponent of the final value in the array. 44 | integer(int32), intent(in) :: npts 45 | !! The number of values in the array. 46 | real(real64), allocatable, dimension(:) :: x 47 | !! The resulting array. 48 | 49 | ! Local Variables 50 | integer(int32) :: i 51 | real(real64) :: dx, exponent 52 | 53 | ! Process 54 | allocate(x(npts)) 55 | dx = (finish - start) / (npts - 1.0d0) 56 | exponent = start 57 | do i = 1, npts 58 | x(i) = 1.0d1**exponent 59 | exponent = exponent + dx 60 | end do 61 | end function 62 | 63 | ! ------------------------------------------------------------------------------ 64 | pure function meshgrid(x, y) result(xy) 65 | !! Constructs two matrices (X and Y) from x and y data arrays. 66 | real(real64), intent(in), dimension(:) :: x 67 | !! An M-element array of x data points. 68 | real(real64), intent(in), dimension(:) :: y 69 | !! An N-element array of y data points. 70 | real(real64), allocatable, dimension(:,:,:) :: xy 71 | !! An N-by-M-by-2 array containing the x data matrix on the first 72 | !! page of the array, and the y data matrix on the second page. 73 | 74 | ! Local Variables 75 | integer(int32) :: i, nx, ny 76 | 77 | ! Process 78 | nx = size(x) 79 | ny = size(y) 80 | allocate(xy(ny, nx, 2)) 81 | do i = 1, ny 82 | xy(i,:,1) = x 83 | end do 84 | do i = 1, nx 85 | xy(:,i,2) = y 86 | end do 87 | end function 88 | 89 | end module 90 | -------------------------------------------------------------------------------- /src/fplot_errors.f90: -------------------------------------------------------------------------------- 1 | module fplot_errors 2 | use iso_fortran_env 3 | use ferror 4 | implicit none 5 | 6 | ! ****************************************************************************** 7 | ! ERROR CODES 8 | ! ------------------------------------------------------------------------------ 9 | integer(int32), parameter :: PLOT_OUT_OF_MEMORY_ERROR = 1000 10 | !! Occurs if there is insufficient memory available for the 11 | !! requested operation. 12 | integer(int32), parameter :: PLOT_INVALID_INPUT_ERROR = 1001 13 | !! Occurs if an invalid input is provided. 14 | integer(int32), parameter :: PLOT_INVALID_OPERATION_ERROR = 1002 15 | !! Occurs if an attempt is made to perform an invalid operation. 16 | integer(int32), parameter :: PLOT_ARRAY_SIZE_MISMATCH_ERROR = 1003 17 | !! Occurs if there is an array size mismatch error. 18 | integer(int32), parameter :: PLOT_GNUPLOT_FILE_ERROR = 1004 19 | !! Occurs if there is a GNUPLOT file error. 20 | 21 | contains 22 | ! ------------------------------------------------------------------------------ 23 | subroutine report_memory_error(err, fcn, flag) 24 | !! Reports a memory allocation error. 25 | class(errors), intent(inout) :: err 26 | !! The error handling object. 27 | character(len = *), intent(in) :: fcn 28 | !! The name of the function or subroutine in which the error occurred. 29 | integer(int32), intent(in) :: flag 30 | !! The error flag returned by the system. 31 | 32 | ! Local Variables 33 | character(len = 256) :: msg 34 | 35 | ! Define the error message 36 | write(100, msg) "Memory allocation error returning flag ", flag, "." 37 | call err%report_error(fcn, trim(msg), PLOT_OUT_OF_MEMORY_ERROR) 38 | 39 | ! Formatting 40 | 100 format(A, I0, A) 41 | end subroutine 42 | 43 | ! ------------------------------------------------------------------------------ 44 | subroutine report_file_create_error(err, fcn, fname, flag) 45 | !! Reports an I/O error related to file creating. 46 | class(errors), intent(inout) :: err 47 | !! The error handling object. 48 | character(len = *), intent(in) :: fcn 49 | !! The name of the function or subroutine in which the error occurred. 50 | character(len = *), intent(in) :: fname 51 | !! The filename. 52 | integer(int32), intent(in) :: flag 53 | !! The error flag returned by the system. 54 | 55 | ! Local Variables 56 | character(len = 2048) :: msg 57 | 58 | ! Define the error message 59 | write(100, msg) "File ", fname, " could not be created. The error flag ", & 60 | flag, " was returned." 61 | call err%report_error(fcn, trim(msg), PLOT_GNUPLOT_FILE_ERROR) 62 | 63 | ! Formatting 64 | 100 format(A, A, A, I0, A) 65 | end subroutine 66 | 67 | ! ------------------------------------------------------------------------------ 68 | subroutine report_array_size_mismatch_error(err, fcn, name, expected, actual) 69 | !! Reports an array size mismatch error. 70 | class(errors), intent(inout) :: err 71 | !! The error handling object. 72 | character(len = *), intent(in) :: fcn 73 | !! The name of the function or subroutine in which the error occurred. 74 | character(len = *), intent(in) :: name 75 | !! The variable name. 76 | integer(int32), intent(in) :: expected 77 | !! The expected array size. 78 | integer(int32), intent(in) :: actual 79 | !! The actual array size. 80 | 81 | ! Local Variables 82 | character(len = 256) :: msg 83 | 84 | ! Define the message 85 | write(100, msg) "Array ", name, " was found to be of length ", actual, & 86 | ", but was expected to be of length ", expected, "." 87 | call err%report_error(fcn, trim(msg), PLOT_ARRAY_SIZE_MISMATCH_ERROR) 88 | 89 | ! Formatting 90 | 100 format(A, A, A, I0, A, I0, A) 91 | end subroutine 92 | 93 | ! ------------------------------------------------------------------------------ 94 | subroutine report_matrix_size_mismatch_error(err, fcn, name, mexp, nexp, & 95 | mact, nact) 96 | !! Reports a matrix size mismatch error. 97 | class(errors), intent(inout) :: err 98 | !! The error handling object. 99 | character(len = *), intent(in) :: fcn 100 | !! The name of the function or subroutine in which the error occurred. 101 | character(len = *), intent(in) :: name 102 | !! The variable name. 103 | integer(int32), intent(in) :: mexp 104 | !! The expected number of rows. 105 | integer(int32), intent(in) :: nexp 106 | !! The expected number of columns. 107 | integer(int32), intent(in) :: mact 108 | !! The actual number of rows. 109 | integer(int32), intent(in) :: nact 110 | !! The actual number of columns. 111 | 112 | ! Local Variables 113 | character(len = 256) :: msg 114 | 115 | ! Define the error 116 | write(100, msg) "Matrix ", name, " was expected to be of size ", mexp, & 117 | "-by-", nexp, ", but was found to be of size ", mact, "-by-", nact, "." 118 | call err%report_error(fcn, trim(msg), PLOT_ARRAY_SIZE_MISMATCH_ERROR) 119 | 120 | ! Formatting 121 | 100 format(A, A, A, I0, A, I0, A, I0, A, I0, A) 122 | end subroutine 123 | 124 | ! ------------------------------------------------------------------------------ 125 | end module -------------------------------------------------------------------------------- /src/fplot_label.f90: -------------------------------------------------------------------------------- 1 | ! fplot_label.f90 2 | 3 | module fplot_label 4 | use iso_fortran_env 5 | use fplot_plot_object 6 | use fplot_constants 7 | use strings 8 | implicit none 9 | private 10 | public :: plot_label 11 | 12 | type, extends(plot_object) :: plot_label 13 | !! Defines a plot label. 14 | logical, private :: m_visible = .true. 15 | !! Is the label visible? 16 | real(real32), private, dimension(3) :: m_position 17 | !! The x, y, and z coordinates of the label. 18 | real(real32), private :: m_angle = 0.0 19 | !! The rotation angle of the label. 20 | character(len = PLOTDATA_MAX_NAME_LENGTH), private :: m_text 21 | !! The label text. 22 | contains 23 | procedure, public :: get_command_string => lbl_get_cmd 24 | procedure, public :: get_is_visible => lbl_get_is_visible 25 | procedure, public :: set_is_visible => lbl_set_is_visible 26 | procedure, public :: get_position => lbl_get_position 27 | procedure, public :: set_position => lbl_set_position 28 | procedure, public :: get_angle => lbl_get_angle 29 | procedure, public :: set_angle => lbl_set_angle 30 | procedure, public :: get_text => lbl_get_txt 31 | procedure, public :: set_text => lbl_set_txt 32 | end type 33 | contains 34 | ! ------------------------------------------------------------------------------ 35 | function lbl_get_cmd(this) result(x) 36 | !! Gets the GNUPLOT command string for the label. 37 | class(plot_label), intent(in) :: this 38 | !! The plot_label object. 39 | character(len = :), allocatable :: x 40 | !! The command string. 41 | 42 | ! Local Variables 43 | type(string_builder) :: str 44 | real(real32) :: pt(3) 45 | 46 | ! Initialization 47 | call str%initialize() 48 | pt = this%get_position() 49 | 50 | ! If visible, draw the label 51 | if (this%get_is_visible()) then 52 | call str%append('set label "') 53 | call str%append(this%get_text()) 54 | call str%append('"') 55 | 56 | call str%append(" at ") 57 | call str%append(to_string(pt(1))) 58 | call str%append(",") 59 | call str%append(to_string(pt(2))) 60 | call str%append(",") 61 | call str%append(to_string(pt(3))) 62 | 63 | call str%append(" rotate by ") 64 | call str%append(to_string(this%get_angle())) 65 | 66 | x = char(str%to_string()) 67 | end if 68 | end function 69 | 70 | ! ------------------------------------------------------------------------------ 71 | pure function lbl_get_is_visible(this) result(x) 72 | !! Gets a value determining if the label is to be drawn. 73 | class(plot_label), intent(in) :: this 74 | !! The plot_label object. 75 | logical :: x 76 | !! Returns true if the label is to be drawn; else, false. 77 | x = this%m_visible 78 | end function 79 | 80 | ! -------------------- 81 | subroutine lbl_set_is_visible(this, x) 82 | !! Sets a value determining if the label is to be drawn. 83 | class(plot_label), intent(inout) :: this 84 | !! The plot_label object. 85 | logical, intent(in) :: x 86 | !! Set to true if the label is to be drawn; else, false. 87 | this%m_visible = x 88 | end subroutine 89 | 90 | ! ------------------------------------------------------------------------------ 91 | pure function lbl_get_position(this) result(x) 92 | !! Gets the position of the label in terms of plot coordinates. 93 | class(plot_label), intent(in) :: this 94 | !! The plot_label object. 95 | real(real32), dimension(3) :: x 96 | !! A 3-element array containing the X, Y, and Z position of the 97 | !! label. 98 | x = this%m_position 99 | end function 100 | 101 | ! -------------------- 102 | subroutine lbl_set_position(this, x) 103 | !! Sets the position of the label in terms of plot coordinates. 104 | class(plot_label), intent(inout) :: this 105 | !! The plot_label object. 106 | real(real32), intent(in), dimension(3) :: x 107 | !! A 3-element array containing the X, Y, and Z position of the 108 | !! label. 109 | this%m_position = x 110 | end subroutine 111 | 112 | ! ------------------------------------------------------------------------------ 113 | pure function lbl_get_angle(this) result(x) 114 | !! Gets the angle of the label text, in degrees. 115 | class(plot_label), intent(in) :: this 116 | !! The plot_label object. 117 | real(real32) :: x 118 | !! The angle, in degrees. 119 | x = this%m_angle 120 | end function 121 | 122 | ! -------------------- 123 | subroutine lbl_set_angle(this, x) 124 | !! Sets the angle of the label text, in degrees. 125 | class(plot_label), intent(inout) :: this 126 | !! The plot_label object. 127 | real(real32), intent(in) :: x 128 | !! The angle, in degrees. 129 | this%m_angle = x 130 | end subroutine 131 | 132 | ! ------------------------------------------------------------------------------ 133 | function lbl_get_txt(this) result(x) 134 | !! Gets the text displayed by the label. 135 | class(plot_label), intent(in) :: this 136 | !! The plot_label object. 137 | character(len = :), allocatable :: x 138 | !! The text string to display. 139 | x = trim(this%m_text) 140 | end function 141 | 142 | ! -------------------- 143 | subroutine lbl_set_txt(this, x) 144 | !! Sets the text displayed by the label. 145 | class(plot_label), intent(inout) :: this 146 | !! The plot_label object. 147 | character(len = *), intent(in) :: x 148 | !! The text string to display. 149 | integer(int32) :: n 150 | n = min(len(x), PLOTDATA_MAX_NAME_LENGTH) 151 | this%m_text = "" 152 | this%m_text(1:n) = x(1:n) 153 | end subroutine 154 | 155 | ! ****************************************************************************** 156 | ! ADDED: JAN. 09, 2024 - JAC 157 | ! ------------------------------------------------------------------------------ 158 | ! pure subroutine lbl_assign(x, y) 159 | ! type(plot_label), intent(out) :: x 160 | ! class(plot_label), intent(in) :: y 161 | ! x%m_visible = y%m_visible 162 | ! x%m_position = y%m_position 163 | ! x%m_angle = y%m_angle 164 | ! x%m_text = y%m_text 165 | ! end subroutine 166 | 167 | ! ------------------------------------------------------------------------------ 168 | end module 169 | -------------------------------------------------------------------------------- /src/fplot_latex_terminal.f90: -------------------------------------------------------------------------------- 1 | ! fplot_latex_terminal.f90 2 | 3 | module fplot_latex_terminal 4 | use iso_fortran_env 5 | use fplot_terminal 6 | use fplot_constants 7 | use strings 8 | implicit none 9 | private 10 | public :: latex_terminal 11 | 12 | type, extends(terminal) :: latex_terminal 13 | !! A LATEX terminal. 14 | character(len = 14), private :: m_id = "epslatex color" 15 | !! The terminal ID string 16 | character(len = GNUPLOT_MAX_PATH_LENGTH), private :: m_fname = "default.tex" 17 | !! The filename of the file to write. 18 | contains 19 | procedure, public :: get_filename => tex_get_filename 20 | procedure, public :: set_filename => tex_set_filename 21 | procedure, public :: get_id_string => tex_get_term_string 22 | procedure, public :: get_command_string => tex_get_command_string 23 | end type 24 | 25 | contains 26 | ! ------------------------------------------------------------------------------ 27 | function tex_get_term_string(this) result(x) 28 | !! Retrieves a GNUPLOT terminal identifier string. 29 | class(latex_terminal), intent(in) :: this 30 | !! The latex_terminal object. 31 | character(len = :), allocatable :: x 32 | !! The string. 33 | integer(int32) :: n 34 | n = len_trim(this%m_id) 35 | allocate(character(len = n) :: x) 36 | x = this%m_id 37 | end function 38 | 39 | ! ------------------------------------------------------------------------------ 40 | function tex_get_filename(this) result(txt) 41 | !! Gets the filename for the output LATEX file. 42 | class(latex_terminal), intent(in) :: this 43 | !! The latex_terminal object. 44 | character(len = :), allocatable :: txt 45 | !! The filename, including the file extension (.tex). 46 | integer(int32) :: n 47 | n = len_trim(this%m_fname) 48 | allocate(character(len = n) :: txt) 49 | txt = trim(this%m_fname) 50 | end function 51 | 52 | ! -------------------- 53 | subroutine tex_set_filename(this, txt) 54 | !! Sets the filename for the output LATEX file. 55 | class(latex_terminal), intent(inout) :: this 56 | !! The latex_terminal object. 57 | character(len = *), intent(in) :: txt 58 | !! The filename, including the file extension (.tex). 59 | integer(int32) :: n 60 | n = min(len_trim(txt), GNUPLOT_MAX_PATH_LENGTH) 61 | this%m_fname = "" 62 | if (n /= 0) then 63 | this%m_fname(1:n) = txt(1:n) 64 | else 65 | this%m_fname = "default.tex" 66 | end if 67 | end subroutine 68 | 69 | ! ------------------------------------------------------------------------------ 70 | function tex_get_command_string(this) result(x) 71 | !! Returns the appropriate GNUPLOT command string to establish 72 | !! appropriate parameters. 73 | class(latex_terminal), intent(in) :: this 74 | !! The latex_terminal object. 75 | character(len = :), allocatable :: x 76 | !! The GNUPLOT command string. 77 | 78 | ! Local Variables 79 | type(string_builder) :: str 80 | 81 | ! Process 82 | call str%initialize() 83 | call str%append("set term epslatex color ") 84 | call str%append(" font ") 85 | call str%append('"') 86 | call str%append(this%get_font_name()) 87 | call str%append(',') 88 | call str%append(to_string(this%get_font_size())) 89 | call str%append('"') 90 | call str%append(" size ") 91 | call str%append(to_string(this%get_window_width())) 92 | call str%append(",") 93 | call str%append(to_string(this%get_window_height())) 94 | call str%append(new_line('a')) 95 | call str%append("set output ") 96 | call str%append('"') 97 | call str%append(this%get_filename()) 98 | call str%append('"') 99 | x = char(str%to_string()) 100 | end function 101 | 102 | end module 103 | -------------------------------------------------------------------------------- /src/fplot_plot_bar.f90: -------------------------------------------------------------------------------- 1 | ! fplot_plot_bar.f90 2 | 3 | module fplot_plot_bar 4 | use iso_fortran_env 5 | use fplot_plot_2d 6 | use strings 7 | implicit none 8 | private 9 | public :: plot_bar 10 | 11 | type, extends(plot_2d) :: plot_bar 12 | !! Defines a 2D plot tailored towards bar plotting. 13 | real(real32), private :: m_barWidth = 1.0d0 14 | !! A relative scaling of the width of a single bar. The value 15 | !! must be between 0 and 1 with 1 being full width. 16 | contains 17 | procedure, public :: get_bar_width => pb_get_bar_width 18 | procedure, public :: set_bar_width => pb_set_bar_width 19 | procedure, public :: get_command_string => pb_get_cmd 20 | end type 21 | 22 | contains 23 | ! ------------------------------------------------------------------------------ 24 | pure function pb_get_bar_width(this) result(x) 25 | !! Gets the bar width scaling factor. 26 | class(plot_bar), intent(in) :: this 27 | !! The plot_bar object. 28 | real(real32) :: x 29 | !! The scaling factor. 30 | x = this%m_barWidth 31 | end function 32 | 33 | ! ------------------------------------------------------------------------------ 34 | subroutine pb_set_bar_width(this, x) 35 | !! Sets the bar width scaling factor. 36 | class(plot_bar), intent(inout) :: this 37 | !! The plot_bar object. 38 | real(real32), intent(in) :: x 39 | !! The scaling factor. The value must be in the set [0, 1]; else, the 40 | !! value will be shifted accordingly. 41 | if (x > 1.0) then 42 | this%m_barWidth = 1.0 43 | else if (x < 0.0) then 44 | this%m_barWidth = 0.0 45 | else 46 | this%m_barWidth = x 47 | end if 48 | end subroutine 49 | 50 | ! ------------------------------------------------------------------------------ 51 | function pb_get_cmd(this) result(x) 52 | !! Gets the GNUPLOT commands required to draw the plot. 53 | class(plot_bar), intent(in) :: this 54 | !! The plot_bar object. 55 | character(len = :), allocatable :: x 56 | !! The command string. 57 | 58 | ! Local Variables 59 | type(string_builder) :: str 60 | 61 | ! Initialization 62 | call str%initialize() 63 | 64 | ! Box Width 65 | call str%append(new_line('a')) 66 | call str%append("set boxwidth ") 67 | call str%append(to_string(this%get_bar_width())) 68 | call str%append(" relative") 69 | 70 | ! Call the base routine to establish the remainder of the plot 71 | call str%append(this%plot_2d%get_command_string()) 72 | 73 | ! End 74 | x = char(str%to_string()) 75 | end function 76 | 77 | ! ------------------------------------------------------------------------------ 78 | ! TO DO YET: 79 | ! - clustering 80 | ! - stacking 81 | ! - lighting 82 | end module 83 | -------------------------------------------------------------------------------- /src/fplot_plot_object.f90: -------------------------------------------------------------------------------- 1 | module fplot_plot_object 2 | use iso_fortran_env 3 | implicit none 4 | 5 | type, abstract :: plot_object 6 | !! The base type for all plot objects. 7 | contains 8 | procedure(get_string_result), deferred, public :: get_command_string 9 | end type 10 | 11 | interface 12 | function get_string_result(this) result(x) 13 | !! Returns a string from a plot_object. 14 | import plot_object 15 | class(plot_object), intent(in) :: this 16 | !! The plot_object object. 17 | character(len = :), allocatable :: x 18 | !! The result string. 19 | end function 20 | end interface 21 | end module -------------------------------------------------------------------------------- /src/fplot_png_terminal.f90: -------------------------------------------------------------------------------- 1 | ! fplot_png_terminal.f90 2 | 3 | module fplot_png_terminal 4 | use iso_fortran_env 5 | use strings 6 | use fplot_terminal 7 | use fplot_constants 8 | implicit none 9 | private 10 | public :: png_terminal 11 | 12 | type, extends(terminal) :: png_terminal 13 | !! Defines a terminal used for producing PNG outputs. 14 | character(len = 3), private :: m_id = "png" 15 | !! The terminal ID string 16 | character(len = GNUPLOT_MAX_PATH_LENGTH), private :: m_fname = "default.png" 17 | !! The filename of the PNG file to write. 18 | contains 19 | procedure, public :: get_filename => png_get_filename 20 | procedure, public :: set_filename => png_set_filename 21 | procedure, public :: get_id_string => png_get_term_string 22 | procedure, public :: get_command_string => png_get_command_string 23 | end type 24 | 25 | contains 26 | ! ------------------------------------------------------------------------------ 27 | function png_get_term_string(this) result(x) 28 | !! Retrieves a GNUPLOT terminal identifier string. 29 | class(png_terminal), intent(in) :: this 30 | !! The png_terminal object. 31 | character(len = :), allocatable :: x 32 | !! The string. 33 | integer(int32) :: n 34 | n = len_trim(this%m_id) 35 | allocate(character(len = n) :: x) 36 | x = this%m_id 37 | end function 38 | 39 | ! ------------------------------------------------------------------------------ 40 | function png_get_filename(this) result(txt) 41 | !! Gets the filename for the output PNG file. 42 | class(png_terminal), intent(in) :: this 43 | !! The png_terminal object. 44 | character(len = :), allocatable :: txt 45 | !! The filename, including the file extension (.png). 46 | integer(int32) :: n 47 | n = len_trim(this%m_fname) 48 | allocate(character(len = n) :: txt) 49 | txt = trim(this%m_fname) 50 | end function 51 | 52 | ! -------------------- 53 | subroutine png_set_filename(this, txt) 54 | !!Sets the filename for the output PNG file. 55 | class(png_terminal), intent(inout) :: this 56 | !! The png_terminal object. 57 | character(len = *), intent(in) :: txt 58 | !! The filename, including the file extension (.png). 59 | integer(int32) :: n 60 | n = min(len_trim(txt), GNUPLOT_MAX_PATH_LENGTH) 61 | this%m_fname = "" 62 | if (n /= 0) then 63 | this%m_fname(1:n) = txt(1:n) 64 | else 65 | this%m_fname = "default.png" 66 | end if 67 | end subroutine 68 | 69 | ! ------------------------------------------------------------------------------ 70 | function png_get_command_string(this) result(x) 71 | !! Returns the appropriate GNUPLOT command string to establish 72 | !! appropriate parameters. 73 | class(png_terminal), intent(in) :: this 74 | !! The png_terminal object. 75 | character(len = :), allocatable :: x 76 | !! The GNUPLOT command string. 77 | 78 | ! Local Variables 79 | type(string_builder) :: str 80 | 81 | ! Process 82 | call str%initialize() 83 | call str%append("set term pngcairo enhanced ") 84 | call str%append(" font ") 85 | call str%append('"') 86 | call str%append(this%get_font_name()) 87 | call str%append(',') 88 | call str%append(to_string(this%get_font_size())) 89 | call str%append('"') 90 | call str%append(" size ") 91 | call str%append(to_string(this%get_window_width())) 92 | call str%append(",") 93 | call str%append(to_string(this%get_window_height())) 94 | call str%append(new_line('a')) 95 | call str%append("set output ") 96 | call str%append('"') 97 | call str%append(this%get_filename()) 98 | call str%append('"') 99 | x = char(str%to_string()) 100 | end function 101 | 102 | end module -------------------------------------------------------------------------------- /src/fplot_qt_terminal.f90: -------------------------------------------------------------------------------- 1 | ! fplot_qt_terminal.f90 2 | 3 | module fplot_qt_terminal 4 | use iso_fortran_env 5 | use fplot_terminal 6 | implicit none 7 | private 8 | public :: qt_terminal 9 | 10 | type, extends(terminal) :: qt_terminal 11 | !! Defines a terminal that utilizes QT. 12 | character(len = 2), private :: m_id = "qt" 13 | !! The terminal ID string 14 | contains 15 | procedure, public :: get_id_string => qt_get_term_string 16 | end type 17 | 18 | contains 19 | function qt_get_term_string(this) result(x) 20 | !! Retrieves a GNUPLOT terminal identifier string. 21 | class(qt_terminal), intent(in) :: this 22 | !! The qt_terminal object. 23 | character(len = :), allocatable :: x 24 | !! The string. 25 | integer(int32) :: n 26 | n = len_trim(this%m_id) 27 | allocate(character(len = n) :: x) 28 | x = this%m_id 29 | end function 30 | end module 31 | -------------------------------------------------------------------------------- /src/fplot_windows_terminal.f90: -------------------------------------------------------------------------------- 1 | ! fplot_windows_terminal.f90 2 | 3 | module fplot_windows_terminal 4 | use iso_fortran_env 5 | use fplot_terminal 6 | implicit none 7 | private 8 | public :: windows_terminal 9 | 10 | type, extends(terminal) :: windows_terminal 11 | !! A Windows-specific terminal. 12 | character(len = 3), private :: m_id = "win" 13 | !! The terminal ID string 14 | contains 15 | procedure, public :: get_id_string => wt_get_term_string 16 | end type 17 | 18 | contains 19 | 20 | function wt_get_term_string(this) result(x) 21 | !! Retrieves a GNUPLOT terminal identifier string. 22 | class(windows_terminal), intent(in) :: this 23 | !! The windows_terminal object. 24 | character(len = :), allocatable :: x 25 | !! The string. 26 | integer(int32) :: n 27 | n = len_trim(this%m_id) 28 | allocate(character(len = n) :: x) 29 | x = this%m_id 30 | end function 31 | 32 | end module 33 | -------------------------------------------------------------------------------- /src/fplot_wxt_terminal.f90: -------------------------------------------------------------------------------- 1 | ! fplot_wxt_terminal.f90 2 | 3 | module fplot_wxt_terminal 4 | use iso_fortran_env 5 | use fplot_terminal 6 | implicit none 7 | private 8 | public :: wxt_terminal 9 | 10 | type, extends(terminal) :: wxt_terminal 11 | !! A WXT terminal. 12 | character(len = 3), private :: m_id = "wxt" 13 | !! The terminal ID string 14 | contains 15 | procedure, public :: get_id_string => wxt_get_term_string 16 | end type 17 | 18 | contains 19 | function wxt_get_term_string(this) result(x) 20 | !! Retrieves a GNUPLOT terminal identifier string. 21 | class(wxt_terminal), intent(in) :: this 22 | !! The wxt_terminal object. 23 | character(len = :), allocatable :: x 24 | !! The string. 25 | integer(int32) :: n 26 | n = len_trim(this%m_id) 27 | allocate(character(len = n) :: x) 28 | x = this%m_id 29 | end function 30 | end module 31 | -------------------------------------------------------------------------------- /src/meson.build: -------------------------------------------------------------------------------- 1 | sources = files( 2 | 'fplot_axis.f90', 3 | 'fplot_colormap.f90', 4 | 'fplot_colors.f90', 5 | 'fplot_core.f90', 6 | 'fplot_core_routines.f90', 7 | 'fplot_delaunay_tri_surface.f90', 8 | 'fplot_filled_plot_data.f90', 9 | 'fplot_label.f90', 10 | 'fplot_latex_terminal.f90', 11 | 'fplot_legend.f90', 12 | 'fplot_multiplot.f90', 13 | 'fplot_plot_2d.f90', 14 | 'fplot_plot_3d.f90', 15 | 'fplot_plot_axis.f90', 16 | 'fplot_plot_bar.f90', 17 | 'fplot_plot_data_2d.f90', 18 | 'fplot_plot_data_3d.f90', 19 | 'fplot_plot_data_bar.f90', 20 | 'fplot_plot_data_colored.f90', 21 | 'fplot_plot_data_error_bars.f90', 22 | 'fplot_plot_data.f90', 23 | 'fplot_plot_data_histogram.f90', 24 | 'fplot_plot_data_tri_2d.f90', 25 | 'fplot_plot.f90', 26 | 'fplot_plot_polar.f90', 27 | 'fplot_png_terminal.f90', 28 | 'fplot_qt_terminal.f90', 29 | 'fplot_scatter_plot_data.f90', 30 | 'fplot_simplify.f90', 31 | 'fplot_surface_plot_data.f90', 32 | 'fplot_surface_plot.f90', 33 | 'fplot_terminal.f90', 34 | 'fplot_tri_surface_plot_data.f90', 35 | 'fplot_vector_field_plot_data.f90', 36 | 'fplot_windows_terminal.f90', 37 | 'fplot_wxt_terminal.f90', 38 | 'geompack.f', 39 | 'tripack.f', 40 | 'fplot_string_builder.f90', 41 | 'fplot_string_builder_implementation.f90', 42 | 'fplot_triangulations_delaunay_2d.f90' 43 | ) 44 | -------------------------------------------------------------------------------- /subprojects/fcore.wrap: -------------------------------------------------------------------------------- 1 | [wrap-git] 2 | url=git@github.com:AtilaSaraiva/fcore.git 3 | revision=meson 4 | -------------------------------------------------------------------------------- /subprojects/ferror.wrap: -------------------------------------------------------------------------------- 1 | [wrap-redirect] 2 | filename = fcore/subprojects/ferror.wrap 3 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake") 2 | add_subdirectory(fortran_test_helper) 3 | 4 | set(fplot_test_sources 5 | fplot_test.f90 6 | fplot_3d_test.f90 7 | fplot_arrow_test.f90 8 | ) 9 | 10 | add_executable(fplot_test ${fplot_test_sources}) 11 | link_library(fplot_test ${PROJECT_NAME} ${PROJECT_INCLUDE_DIR}) 12 | link_library(fplot_test ${fortran_test_helper_LIBRARY} ${fortran_test_helper_INCLUDE_DIR}) 13 | add_test( 14 | NAME fplot_test 15 | WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} 16 | COMMAND $ 17 | ) -------------------------------------------------------------------------------- /test/fortran_test_helper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Get the macros and functions we'll need 2 | include("${PROJECT_SOURCE_DIR}/cmake/helper.cmake") 3 | include(FetchContent) 4 | 5 | # Fetch the proper content 6 | FetchContent_Declare( 7 | fortran_test_helper 8 | GIT_REPOSITORY "https://github.com/jchristopherson/fortran_test_helper" 9 | GIT_TAG main 10 | ) 11 | 12 | FetchContent_MakeAvailable(fortran_test_helper) 13 | 14 | if (WIN32) 15 | if (BUILD_SHARED_LIBS) 16 | add_custom_command( 17 | TARGET ${PROJECT_NAME} POST_BUILD 18 | COMMAND ${CMAKE_COMMAND} -E copy_if_different 19 | $ 20 | $