plot graph

how to draw a x-y plot in fortran using this compiler

Plotting (and, more generally, controlling devices) is outside the scope of Fortran.

You may output a text or “binary” stream from a Fortran program, either directly (e.g., PostScript output, GNUPlot commands, CalComp commands, HP-GL) or through an API (e.g., an image format such as JPEG). There are raster-oriented APIs, and there are vector-oriented APIs.

Search on “GNUPLOT”, “PSPLOT”, “DISLIN”, etc.

Hi kuldeep gupta,

You can use OpenGL to create basic plots. There are few interface libraries which can help. While I wrote this guide to building F90gl for the PGI 6.0 compilers, it’s still valid for our latest versions. There is also newer F03gl library (, but I have not personally used it.

If you need an example program, I used F90gl as part of my CUDA Fortran “Games of Life” program found in this article:

  • Mat