In this section:
ClearWin (without the +) was originally marketed as a separately-priced add on to the FTN77 compiler, although it eventually was rolled into the package, and as the system developed, the + was added. At some point a graph-drawing facility was also added to work with ClearWin+, with a very basic set of functions supplied as standard, and the more advanced graph drawing facilities supplied in another separate third-party package complete with its own manual. The name of the graph drawing package was SimplePlot, and it was invoked by use of the %pl format code. Eventually, and I’m not clear on when that was, the full SimplePlot stopped being available.
With the development of the 64-bit version of FTN95, Silverfrost undertook the development of a more sophisticated version of SimplePlot which they called native SimplePlot. Not only does the new graph plotting code offer a lot of options, but also it is drawn with GDI+, and therefore has an extremely attractive appearance. It is however not fully developed at the time I write this, and it does seem to me that for many purposes you might just as well draw your own graphs and charts in a %gr drawing surface whether that is a drawing surface on the client area of a master window, or as part of a dialog.
Engineers and scientists are probably most familiar with a graph with linear or logarithmic cartesian coordinate axes, but there are many more ways of graphing data. The Silverfrost website contains a link to Simfit and Simdem, packages provided as open source by their now-retired author, Bill (W.G.) Bardsley, formerly of the University of Manchester, and no doubt even if you do not require the whole package, you may well find a routine or routines that you find useful in your application. Acknowledgement then would surely be required, both in your Help file and perhaps also in your About dialog box.
So there are a number of choices to help you draw graphs.
One of the great things about doing something for yourself is the total control you have, and what is more, the ability you have to tailor the plot appearance to the needs of your analysis, and to produce hardcopy, especially when that is integrated with text.
You probably can find the ranges within your dataset to plot by means of straightforward Fortran, but it is always a little trickier to determine the ranges for your axes. Routines for this and many other purposes can be found freely distributed on the internet, and in commercial subroutine libraries. If you do it yourself, or are looking for ideas on how to present the results your program has produced, then you could do worse than spend some time reading the books by Edward Tufte on presenting information in graphical form. There are 4 books, all self-published by the Author and not cheap. I have given a reference to the titles and to Tufte’s website in an Appendix. I sometimes find Tufte to be bombastic and over-opinionated, but his writing gives you food for thought. In particular, Tufte is disparaging about the textures applied to monochrome graphics which he calls ‘chart junk’, forgetting that it was once all there was that could differentiate areas on a monochrome device, and that various forms of crosshatching used by engineering draftsmen when using pen and ink don’t necessarily work so well on raster devices as they do on vector ones. However, colour is almost always better, even if it is only greyscale.
Now suppose that you have plotted a graph as what Excel might describe as a ‘scatter plot’, and that you wish a user to be able to click on the graph and return the x,y values. You must not forget that the mouse cursor has to return the pixel coordinates, and almost inevitably, that means that a conversion to the units used on the graph has the potential to produce irrational numbers with a great many decimal places of apparent precision, but accuracy limited to the nearest pixel, if that. When I have had to program such things, I have found that it is sometimes better to return the value of the nearest plotted point, if that is within a few pixels, or if in a cluster of points to use some sort of averaging on a selection of the nearest points. Weighted averaging using a gravity model (i.e. the weights determined relative to the inverse square of distance) can be useful.
The standard graphics primitives in ClearWin+ are the rectangle and ellipse, but on a graph you will normally want to draw circles and squares. There is then the choice of filled or simply outlined, and then a choice of colour Remember that on screen small radius circles look very blocky. Other symbols common on graphs include *, + and x, but it is difficult to use letters from a font and much better to use polylines or polygons to draw them. You might find the philosophy of the arrow drawing in Appendix A useful if you can create the necessary relative coordinate lists for the markers you want.
Even on hardcopy, you can import bitmaps as the graph symbol markers, but most bitmaps are ‘square’ and do not have transparent backgrounds like icons do, and in addition you will need numerous sizes of each to cover the different DPI settings.
ClearWin+ does permit various line types to be used (look at SET_LINE_STYLE@ and associated routines mentioned in the help file), but they work generally better when a polyline is used rather than a collection of short segments.
Something to think about is the range of values for each axis, and whether or not the scales have to include the origin (0,0). Finding the ranges is easy enough, but deciding the intervals is trickier, as you don’t usually want so many labelled lines on each axis that the labels run together, and for most purposes, you will want useful steps.
For log scales, it is a good idea to select the range so that the axis/axes covers complete log cycles. When that is done it is only necessary to label the multiples of 10 where there is more than one cycle, and the sequence of tick marks does the rest.
FORTRAN and the ART of Windows Programming, Copyright © Eddie Bromhead, 2023.