Clicky

Fortran Wiki
ogpf (changes)

Skip the Navigation Links | Home Page | All Pages | Recently Revised | Authors | Feeds | Export |

Showing changes from revision #13 to #14: (追記) Added (追記ここまで) | (削除) Removed (削除ここまで) | (削除) Chan (削除ここまで)(追記) ged (追記ここまで)

ogpf is an object based Fortran 2003 / Fortran 2008 code implements an interface to gnuplot. A demo(削除) file,a (削除ここまで)(追記) file, (追記ここまで)(追記) a (追記ここまで) brief tutorial and the latest version is available at:github.

Plotting Capabilities

2D Plots

  • plot(v)
  • plot(x,y)
  • plot(x,y, linespec)
  • plot(x1,y1,ls1, x2,y2,ls2, x3,y3,ls3, x4,y4,ls4)
  • plot(x, M)
  • semilogx(x,y)
  • semilogy(x,y)
  • loglog(x,y)

3D Plots

  • surf(x,y,z)
  • surf(x,y,z,lspec)
  • surf(x,y,z, palette)
  • surf(z, palette)
  • contour(x,y,z,palette)
  • contour(z,palette)

Animation

  • animation_start(delay)
  • animation_show()

Multiplot

  • multiplot(rows, cols)

Mathematical Utility Functions

  • linspace(a,b,n)
  • linspace(a,b)
  • arange(a,b,dx)
  • meshgrid(X,Y, xgv,ygv)
  • meshgrid(X,Y, xgv)

Color palette

Nine different color palettes are available. See Ann Schnider gnuplot color palettes and Gnuplotting. These color palettes can be used with:

 surf(x,y,z,palette='plt-name')
 contour(x,y,z,palette='plt-name')
  • set1
  • set2
  • set3
  • palette1
  • palette2
  • paired
  • dark2
  • accent
  • jet

The ogpf library other features

There are a(削除) plenety (削除ここまで)(追記) plenty (追記ここまで) commands to customise the plots. This includes:

  • Plot annotation (e.g. title, xlabel, ylabel, and zlabel)
  • Axes setting (e.g. xrange, yrange, zrange, and grid)
  • Line and marker color and style
  • Gnuplot options (e.g. fonts, tics format, frame format,... )

The ogpf options command

The option command is a very powerful command and can be used to customize the gnuplot in many ways. Options can be set by calling the ogpf options. In every call, it is possible to set several options separated by semicolon or options can be set by several calls. Below shows few samples:

  • Sample 1

Set the legend (key) at the right bottom of window

call gp%options('set key bottom right')

  • Sample 2

Define a new line style

call gp%options('set style line 1 lc rgb "blue" lt 1 lw 2 pt 6 ps 1.5')

  • Sample 3

Use several options each uses separate command

call gp%options('set tics')

call gp%options('set tics font ",8"') ! font size for tics

  • Sample 4

Set several options at the same time using semicolon as delimiter

call gp%options('unset tics; unset colorbox')

Demo

There is a collection of examples in demo.f90 to show the capabilities of ogpf.

Easy to use

To use ogpf in your project, add the library file to your(削除) fortran (削除ここまで)(追記) Fortran (追記ここまで) project (code) * ogpf.f90 (the main library)

For details see ‘demo.f90’

Important Note

To use ogpf on other operating system, you may need to modify the terminal type and fonts in the section of Configuration Parameters. A Makefile has been provided to build the demo from command line.

Example codes

This section shows selected example codes from demo.f90

  • Example 1
 SUBROUTINE Exmp01
 !...............................................................................
 !Example 1: A very basic example
 !...............................................................................
 TYPE(gpf):: gp
 INTEGER, PARAMETER:: n=17
 Real(wp):: x(n)
 Real(wp):: y(n)
 ! Input data
 x=dble([-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8])
 y=dble([66,51,38,27,18,11,6,3,2,3,6,11,18,27,38,51,66])
 ! Annotation: set title, xlabel, ylabel
 CALL gp%title('Example 1. A simple xy plot')
 CALL gp%xlabel('my x axis ...')
 CALL gp%ylabel('my y axis ...')
 Call gp%options('set style data linespoints')
 !Call Plot to draw a vector against a vector of data
 CALL gp%plot(x, y)
 END SUBROUTINE Exmp01

See results in(追記) github (追記ここまで)(追記) . (追記ここまで)

(削除) (削除ここまで)(削除)

github.

(削除ここまで)
Revised on March 3, 2023 11:15:05 by vmagnin (86.67.213.99) (3978 characters / 1.0 pages)
Edit | Back in time (13 revisions) | Hide changes | History | Views: Print | TeX | Source | Linked from: Libraries, Modern Fortran Libraries

AltStyle によって変換されたページ (->オリジナル) /