

The call to set_seriestype configures the style of the series when drawn. Once we’ve provided the first dataset to the plot, we can assign some attributes to the series: call set_seriestype(plot, 0, APLOT_STYLE_PIXEL)Ĭall set_serieslabel(plot, 0, "Random Number") To add data, we must pass an X and Y array to the add_dataset subroutine: call add_dataset(plot, x, rand_y) The next step is to configure each dataset for the plot. In order to provide a little extra space, we’ll expand the plot slightly so that the y-axis varies from 0 to 1.2. In this case, though, we know the data on the y-axis will fall between 0 and 1. The final call, though, to set_yscale might not be as obvious as setting titles and labels. Most calls above are straightforward, and each requires our plot variable as its first argument. Once initialized, we can define some aspects of our plot: call set_title(plot, "Uniform Random Numbers") Before we can use it, though, we must initialize it: plot = initialize_plot() This variable is used for defining all aspects of our plot at eventually displaying it. In order to create a plot, we need to define a plot variable, which is of the aplot_t type: type(aplot_t)::plot
PLOTS IN SIMPLY FORTRAN CODE
This code generates two datasets that we need to plot. The x array is manually populated inside the loop along with the calculation of a running mean in the mean_y array. The random data is created with a single call to RANDOM_NUMBER, which populates the entire rand_y array in one call. Our X-axis data will just be the sample count, though we have to use a REAL variable with Aplot. The code below should be sufficient: real, dimension(1000)::x, rand_y, mean_y To generate our data set, we’ll need to populate some arrays accordingly. There are no other steps to take Simply Fortran will automatically detect this module’s inclusion and configure the compiler to link to the aplot library. On GNU/Linux, Simply Fortran might show the module as unavailable until you click Build Project for the first time. On Windows and macOS, this module will be seamlessly included. In order to use Aplot, the aplot module must be employed in a given procedure: use aplot The plot will therefore include scatter elements and a line, both with a significant amount of data.

This short article will walk through creating a non-trivial plot quickly with Aplot.įor this example, we’ll attempt to plot 1000 random, uniformly distributed numbers along with a running mean as the sample size grows. The programming interface provided is designed to be straightforward, and the library is available on Windows, macOS, and GNU/Linux. With the release of version 2.36, Simply Fortran now includes Aplot, a library for creating simple, two-dimensional plots and charts directly from Fortran. Introducing Aplot Posted: Ap| Author: approximatrix | Filed under: Aplot, Tips and Tricks | Leave a comment
