{"id":22177895,"url":"https://github.com/gasinan/fdata2pyplot","last_synced_at":"2026-01-05T22:11:08.259Z","repository":{"id":50642811,"uuid":"486118396","full_name":"GasinAn/fdata2pyplot","owner":"GasinAn","description":"A simple Fortran module for passing Fortran output to a Python script for later using Matplotlib to make figure","archived":false,"fork":false,"pushed_at":"2024-12-07T13:02:44.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-29T23:16:14.852Z","etag":null,"topics":["fortran","matplotlib","plot"],"latest_commit_sha":null,"homepage":"","language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GasinAn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-27T08:58:43.000Z","updated_at":"2024-12-07T13:02:49.000Z","dependencies_parsed_at":"2022-08-02T23:45:38.683Z","dependency_job_id":"a15f4af6-82b2-4220-bb93-c292e0066779","html_url":"https://github.com/GasinAn/fdata2pyplot","commit_stats":null,"previous_names":["gasinan/fdata2pyplot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GasinAn%2Ffdata2pyplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GasinAn%2Ffdata2pyplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GasinAn%2Ffdata2pyplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GasinAn%2Ffdata2pyplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GasinAn","download_url":"https://codeload.github.com/GasinAn/fdata2pyplot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245326843,"owners_count":20597099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fortran","matplotlib","plot"],"created_at":"2024-12-02T08:33:14.838Z","updated_at":"2026-01-05T22:11:08.231Z","avatar_url":"https://github.com/GasinAn.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fdata2pyplot\n\nA simple Fortran module for passing Fortran output to a Python script for later using Matplotlib to make figure\n\n## Philosophy\n\nFortran is weak in making figure, while Matplotlib is strong in making figure. It is not necessary to reinvent a Fortran wheel of making figure, instead, a simple way to remedy the weakness of Fortran is building a simple bridge from Fortran to Matplotlib.\n\n## Overview\n\nThe module `fdata2pyplot` is defined in `src/fdata2pyplot.f90`. Three public subroutines `fdata2pyplot_pass_data`, `fdata2pyplot_add_others` and `fdata2pyplot_plt` are defined in it.\n\n## Example\n\n```fortran\nprogram test\n    use iso_fortran_env, only: sp =\u003e real32, dp =\u003e real64\n    use fdata2pyplot\n\n    implicit none\n    integer :: i, j\n    real(sp) :: x(-500:500), y(-500:500)\n    real(dp) :: z(-500:500, -500:500)\n\n    x = [(real(i, sp), i=-500, 500)] / 500.0_sp * 3.0_sp\n    y = [(real(j, sp), j=-500, 500)] / 500.0_sp * 3.0_sp\n    do i = -500, 500\n        do j = -500, 500\n            z(i, j) = exp(-x(i)**2.0_sp/2.0_sp) * exp(-y(j)**2.0_sp/2.0_sp)\n        end do\n    end do\n\n    call fdata2pyplot_pass_data(x, \"X\")\n    call fdata2pyplot_pass_data(y, \"Y\")\n    call fdata2pyplot_pass_data(z, \"Z\", \"Gaussian\")\n    call fdata2pyplot_add_others(\"plt.contourf(X, Y, Z)\")\n    call fdata2pyplot_add_others(\"plt.axis('square')\")\n    call fdata2pyplot_add_others(\"plt.show()\")\n    call fdata2pyplot_plt()\nend program test\n```\n\nAfter running this program:\n\n1. Fortran arrays `x`, `y`, `z` will be saved to `X.txt`, `Y.txt` and `Gaussian.txt` respectively;\n\n2. A Python script named `plt.py` will be generated, and it contains:\n```python\nimport numpy as np\nimport matplotlib.pyplot as plt\nX = np.loadtxt('X.txt')\nY = np.loadtxt('Y.txt')\nZ = np.loadtxt('Gaussian.txt')\nplt.contourf(X, Y, Z)\nplt.axis('square')\nplt.show()\n```\n\n3. The Python script `plt.py` will be run for making figure.\n\n## Tips\n\n1. `fdata2pyplot_pass_data` has three dummy arguments: `fortran_arr`, `py_arr_name`, and optional `txt_name`. For convenience, You can only associate `fortran_arr` and `py_arr_name` with effective arguments, and make `py_arr_name` be the name of `fortran_arr`. For example, you can run:\n```fortran\n    call fdata2pyplot_pass_data(x, \"x\")\n    call fdata2pyplot_pass_data(y, \"y\")\n    call fdata2pyplot_pass_data(z, \"z\")\n```\n\n2. In the above example, I called `fdata2pyplot_add_others` several times, which seems to be cumbersome. However, since different operating systems use different line-break characters, I have to do it like this to make the example be safely cross-platform. If you are sure that you will not meet with this trouble, you can call `fdata2pyplot_add_others` one time for adding all \"others\". For example, if you will only run the program on a Unix-like platform, you can run:\n```fortran\n    call fdata2pyplot_add_others(\"plt.contourf(X, Y, Z)\"//new_line('A')// \u0026\n                                 \"plt.axis('square')\"//new_line('A')// \u0026\n                                 \"plt.show()\")\n```\n\n3. Usually we don't know how to make the clearest figure. You need not call `fdata2pyplot_add_others` and `fdata2pyplot_plt`. You can only call `fdata2pyplot_pass_data`, and then modify and run `plt.py` by hand to try different methods of making figure.\n\n## See also\n\n * [Numpy](https://numpy.org/)\n * [Matplotlib](https://matplotlib.org)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgasinan%2Ffdata2pyplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgasinan%2Ffdata2pyplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgasinan%2Ffdata2pyplot/lists"}