Skip to content

sebastian-mutz/fplt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FPLT - Fortran Plotting Library

GitHub 30%

Important

FPLT is in a pre-alpha state, and only suitable for developers at this point.

Description

logo

FPLT is a scientific plotting library for producing high-quality ("publication-ready") figures quickly by leveraging the GMT(Generic Mapping Tools) C-API and modern Fortran's derived types. FPLT includes procedures for producing geographical maps, xy-plots, heat maps, animated figures, and more.

FPLT includes a Fortran interface for several GMT modules (using GMT’s C API). Additional features, provided through an abstraction layer, include Fortran derived types for colour maps, font management, and options for specific kinds of plots. Furthermore, FPLT includes procedures for the automatic construction of colour maps and (the infamously cryptic) GMT argument strings from pre-defined or user-defined options.

The aim is to create a library that lets you:

  • visualise your data directly from your Fortran programme though familiar Fortran-native constructs,
  • produce professional figures quickly through the use of templates and automatic argument construction,
  • modify or create new templates easily from your programme.

Example

The following code modifies a colour map template cmap_bluered01 before creating a temperature map of Europe using the map_default template. All templates are simple derived types with initialised values that can be overwritten, as done with cmap_bluered01 below. The fplt_map subroutine automatically generates gmt arguments (based on map_default template) and works through a stack of gmt modules to successively build your map "behind the scenes".

program main

! load modules and import map template to modify
  use :: fplt, my_map => DAT_map

! basic options
  implicit none

! set output file format
  my_map%infile  = "./test/maps/Mutz_et_al_2018_pd_temp2.asc"

! set plot labels
  my_map%title = "Simulated Temperature (1979-2000)"
  my_map%label_left = "2m air temperature"
  my_map%label_right= "deg C"

! change colour map
  my_map%cmap="bluered01"

! modify preset colour map
  my_map%z_min  = -30
  my_map%z_max  = 30
  my_map%z_step = 1

! change theme
  my_map%theme = "dark"

! change projection
  my_map%projection = "L"

! plot map using the modified copy of the DAT_map template
  call fplt_map(my_map)

end program main

The code above will generate the Lambert conic conformal projection map below (bottom left); not changing the projection will make FPLT default to a Mercator projection (top left). The Miller cylindrical and orthographic projection can be applied by setting the projection to J and G, respectively.

Development

FPLT is mostly developed “as needed” for my research. As such, it will cover a lot of different plot styles, but its features will never be exhaustive. However, you are very welcome to contribute and add new features (through suggestions, coding, etc.) at any stage.

Alpha

I will consider the library to be in "alpha" once FPLT covers all features needed to reproduce ~80% of all the plots I've created in the past ~15 years.

Beta

This stage is reached once:

  • FPLT is able to reproduce all of the above mentioned plots without issues.
  • FPLT fully works with GFortran, LFortran, and Flang compilers.
  • FPLT has proper documentation.

Implemented and Planned Features

Plot Types

100% 75% 0% 0%

Supported Map Projections

Map Projections Arg
Mercator M
Miller Cylindrical J
Cylindrical Equidistant Q
Lambert Conic Conformal L
Albers Conic Equal-Area B
Equidistant Conic D
Transverse Mercator T
Orthographic G

Supported File Formats

Input Covered
grd
text
netcdf -
Output Covered
ps
pdf
png
tif
jpg

Progress Details

Features Implemented
Bindings for GMT's C-API
Geographical maps
Common map projections
Heat maps 75%
XY scatter and line plots -
Bar plots -
GMT argument construction 40%
GMT module templates 30%
GMT auto settings 50%
Themes for plot setting
Auto generate colour maps
Auto label and positioning
Auto crop
Output file format options
Read and convert text
Read and convert netcdf -

Installation

FPLT can be installed/compiled with the fortran package manager (fpm). You will need to make sure you have the Generic Mapping Tools (GMT) 6 lib installed and properly linked.

About

A Fortran plotting library built mostly on GMT (Generic Mapping Tools).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published