Code Monkey home page Code Monkey logo

pyplot-fortran's Introduction

Pyplot-Fortran

A simple module for generating plots from Fortran using Python's matplotlib.pyplot.

Overview

Currently, this module can be used to generate simple plots from Fortran. Eventually, it may be expanded to provide additional features and other types of plots.

The way it works is simply to generate a Python script with the plotting code, which is then executed from the command line using the Fortran execute_command_line function.

The module requires a modern Fortran compiler (it uses various Fortran 2003/2008 features such as deferred-length strings). It should work fine with the latest gfortran or ifort compilers. A simple script build.sh is provided for building the library and test program (requires gfortran and FoBiS). It will also build the HTML documentation if FORD is installed.

Supported plot types

  • matplotlib.pyplot.plot -- 2D/3D plot of lines and/or markers
  • matplotlib.pyplot.bar -- bar plot
  • matplotlib.pyplot.contour -- contour plot
  • matplotlib.pyplot.contourf -- filled contour plot

Example

The following example generates a plot of the sine function:

    program test

    use,intrinsic :: iso_fortran_env, only: wp => real64
    use pyplot_module

    implicit none

    real(wp),dimension(100) :: x,sx
    type(pyplot) :: plt
    integer :: i

    !generate some data:
    x = [(real(i,wp), i=0,size(x)-1)]/5.0_wp
    sx = sin(x)

    !plot it:
    call plt%initialize(grid=.true.,xlabel='angle (rad)',&
                        title='Plot of $\sin(x)$',legend=.true.)
    call plt%add_plot(x,sx,label='$\sin(x)$',linestyle='b-o',markersize=5,linewidth=2)
    call plt%savefig('sinx.png', pyfile='sinx.py')

    end program test

Documentation

  • The API documentation for the current master branch can be found here. This is generated by processing the source files with FORD. Note that the build script will also generate these files automatically in the doc folder, assuming you have FORD installed.

See also

pyplot-fortran's People

Contributors

jacobwilliams avatar szaghi avatar tacaswell avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.