Abstraction layer over Gnuplot.
In order to use terminal PLOT_TERMINAL_GPIC on Linux, Gnuplot must have
been compiled with option gpic enabled. You can list all installed
Gnuplot terminals by running:
$ gnuplot -e "set terminal"
If you build Gnuplot from source, explicitly set option --with-gpic
for PIC preprocessor format, for instance:
$ ./configure --prefix=/opt --with-gpic
Plot data points in SVG format to string svg:
character(:), allocatable :: svg
character(TIME_LEN)       :: ts
integer         :: i, rc
type(plot_type) :: plot
type(dp_type)   :: dps(60)
do i = 1, size(dps)
    write (ts, '("2025-01-01T00:", i0.2, ":00.000000+00:00")') i
    dps(i) = dp_type(ts, sin(i * 0.1_r8))
end do
call dm_plot_set(plot, terminal=PLOT_TERMINAL_SVG, title='Sample Plot', &
                 bidirect=.true., background='white')
rc = dm_plot_lines(plot, dps)
rc = dm_plot_read(plot, svg)
call dm_plot_close(plot)
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | PLOT_STYLE_NONE | = | 0 | 
                 Invalid style.  | 
        
| integer, | public, | parameter | :: | PLOT_STYLE_LINES | = | 1 | 
                 Lines.  | 
        
| integer, | public, | parameter | :: | PLOT_STYLE_LINESPOINTS | = | 2 | 
                 Lines with symbols.  | 
        
| integer, | public, | parameter | :: | PLOT_STYLE_DOTS | = | 3 | 
                 Dots.  | 
        
| integer, | public, | parameter | :: | PLOT_STYLE_POINTS | = | 4 | 
                 Points.  | 
        
| integer, | public, | parameter | :: | PLOT_STYLE_LAST | = | 4 | 
                 Never use this.  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_NONE | = | 0 | 
                 Invalid terminal.  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_ANSI | = | 1 | 
                 ASCII with ANSI colours (dumb).  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_ASCII | = | 2 | 
                 ASCII (dumb).  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_GIF | = | 3 | 
                 GIF (libgd).  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_GPIC | = | 4 | 
                 PIC preprocessor for GNU roff.  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_PNG | = | 5 | 
                 PNG (libgd).  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_PNGCAIRO | = | 6 | 
                 PNG (libcairo).  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_POSTSCRIPT | = | 7 | 
                 PNG (libcairo).  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_SIXELGD | = | 8 | 
                 Sixel (libgd).  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_SIXELTEK | = | 9 | 
                 Sixel (bitmap graphics).  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_SVG | = | 10 | 
                 SVG.  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_X11 | = | 11 | 
                 X11.  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_LAST | = | 11 | 
                 Never use this.  | 
        
| integer, | public, | parameter | :: | PLOT_TERMINAL_NAME_LEN | = | 10 | 
                 Max. terminal name length.  | 
        
| character(len=*), | public, | parameter | :: | PLOT_TIME_FORMAT | = | '%Y-%m-%dT%H:%M:%S' | 
                 Datetime format.  | 
        
| character(len=*), | public, | parameter | :: | PLOT_TERMINAL_NAMES(PLOT_TERMINAL_NONE:PLOT_TERMINAL_LAST) | = | [character(PLOT_TERMINAL_NAME_LEN)::'none', 'ansi', 'ascii', 'gif', 'gpic', 'png', 'pngcairo', 'postscript', 'sixelgd', 'sixeltek', 'svg', 'x11'] | 
                 Gnuplot terminal names.  | 
        
Plot context type.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public | :: | terminal | = | PLOT_TERMINAL_NONE | 
 Output terminal.  | 
        |
| integer, | public | :: | style | = | PLOT_STYLE_LINES | 
 Plot line style.  | 
        |
| integer, | public | :: | width | = | 800 | 
 Plot width [px, cm].  | 
        |
| integer, | public | :: | height | = | 300 | 
 Plot height [px, cm].  | 
        |
| character(len=FILE_PATH_LEN), | public | :: | output | = | ' ' | 
 Output file name.  | 
        |
| character(len=8), | public | :: | background | = | ' ' | 
 Background colour (optional).  | 
        |
| character(len=8), | public | :: | foreground | = | '#3b4cc0' | 
 Foreground colour (optional).  | 
        |
| character(len=8), | public | :: | graph | = | '#ffffff' | 
 Graph background colour.  | 
        |
| character(len=FILE_PATH_LEN), | public | :: | font | = | ' ' | 
 Font name or file path (optional).  | 
        |
| character(len=128), | public | :: | title | = | ' ' | 
 Plot title (optional).  | 
        |
| character(len=128), | public | :: | xlabel | = | ' ' | 
 X label (optional).  | 
        |
| character(len=128), | public | :: | ylabel | = | ' ' | 
 Y label (optional).  | 
        |
| character(len=TIME_LEN), | public | :: | xrange(2) | = | ' ' | 
 X axis range.  | 
        |
| real(kind=r8), | public | :: | yrange(2) | = | 0.0_r8 | 
 Y axis range.  | 
        |
| logical, | public | :: | bidirect | = | .false. | 
 Bi-directional anonymous pipe.  | 
        |
| logical, | public | :: | monochrome | = | .false. | 
 Black and white drawing (PostScript only).  | 
        |
| logical, | public | :: | persist | = | .false. | 
 Persistent Gnuplot process (use only with X11).  | 
        |
| logical, | public | :: | xautoscale | = | .true. | 
 Auto-scale X axis.  | 
        |
| logical, | public | :: | yautoscale | = | .true. | 
 Auto-scale Y axis.  | 
        |
| logical, | public | :: | grid | = | .true. | 
 Show grid.  | 
        |
| logical, | public | :: | legend | = | .false. | 
 Show legend.  | 
        
Returns Gnuplot's standard error output in allocatable character
string output. The result is an empty string of length 1 if no
output to standard error has been made.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(plot_type), | intent(inout) | :: | plot | 
 Plot type.  | 
        ||
| character(len=:), | intent(out), | allocatable | :: | output | 
 Bytes returned by Gnuplot.  | 
        |
| integer(kind=i8), | intent(out), | optional | :: | n | 
 Bytes read.  | 
        
Returns number of bytes read from Gnuplot, and plot data in n. The
output is an empty string of length 1 if no bytes have been returned.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(plot_type), | intent(inout) | :: | plot | 
 Plot type.  | 
        ||
| character(len=:), | intent(out), | allocatable | :: | output | 
 Bytes returned by Gnuplot.  | 
        |
| integer(kind=i8), | intent(out), | optional | :: | n | 
 Bytes read.  | 
        
Returns Gnuplot terminal backend of given name.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name | 
 Terminal name.  | 
        
Returns .true. if the given terminal is valid. PLOT_TERMINAL_NONE
is an invalid terminal.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | terminal | 
 Terminal type enumerator.  | 
        
Returns Gnuplot version as allocatable string. This function is quite slow as Gnuplot has to be started in a new process.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(in), | optional | :: | name | 
 Add prefix   | 
        |
| logical, | intent(out), | optional | :: | found | 
 Returns   | 
        
Version string.
Closes pipe connected to standard error if in bidrectional mode.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(plot_type), | intent(inout) | :: | plot | 
 Plot type.  | 
        
Sets plot attributes.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(plot_type), | intent(inout) | :: | plot | 
 Plot type.  | 
        ||
| integer, | intent(in), | optional | :: | terminal | 
 Output terminal.  | 
        |
| integer, | intent(in), | optional | :: | style | 
 Plot line style.  | 
        |
| integer, | intent(in), | optional | :: | width | 
 Plot width.  | 
        |
| integer, | intent(in), | optional | :: | height | 
 Plot height.  | 
        |
| character(len=*), | intent(in), | optional | :: | output | 
 Output file name.  | 
        |
| character(len=*), | intent(in), | optional | :: | background | 
 Background colour.  | 
        |
| character(len=*), | intent(in), | optional | :: | foreground | 
 Foreground colour.  | 
        |
| character(len=*), | intent(in), | optional | :: | graph | 
 Graph background colour.  | 
        |
| character(len=*), | intent(in), | optional | :: | font | 
 Font name or file path.  | 
        |
| character(len=*), | intent(in), | optional | :: | title | 
 Plot title.  | 
        |
| character(len=*), | intent(in), | optional | :: | xlabel | 
 X axis label.  | 
        |
| character(len=*), | intent(in), | optional | :: | ylabel | 
 Y axis label.  | 
        |
| character(len=*), | intent(in), | optional | :: | xrange(2) | 
 X axis range.  | 
        |
| real(kind=r8), | intent(in), | optional | :: | yrange(2) | 
 Y axis range.  | 
        |
| logical, | intent(in), | optional | :: | bidirect | 
 Bi-directional anonymous pipe.  | 
        |
| logical, | intent(in), | optional | :: | persist | 
 Persistent Gnuplot process (use only with X11).  | 
        |
| logical, | intent(in), | optional | :: | xautoscale | 
 Auto-scale X axis.  | 
        |
| logical, | intent(in), | optional | :: | yautoscale | 
 Auto-scale Y axis.  | 
        |
| logical, | intent(in), | optional | :: | grid | 
 Show grid.  | 
        |
| logical, | intent(in), | optional | :: | legend | 
 Show legend.  | 
        |
| logical, | intent(in), | optional | :: | monochrome | 
 No colour.  |