Simply fortran 2 trial11/18/2023 ![]() On Windows and macOS, this module will be seamlessly included. On GNU/Linux, Simply Fortran might show the module as unavailable until you click Build Project for the first time. 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. 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. Our X-axis data will just be the sample count, though we have to use a REAL variable with Aplot. The random data is created with a single call to RANDOM_NUMBER, which populates the entire rand_y array in one call. The x array is manually populated inside the loop along with the calculation of a running mean in the mean_y array. In order to create a plot, we need to define a plot variable, which is of the aplot_t type: type(aplot_t)::plot This code generates two datasets that we need to plot. ![]() 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. Most calls above are straightforward, and each requires our plot variable as its first argument. The final call, though, to set_yscale might not be as obvious as setting titles and labels. In this case, though, we know the data on the y-axis will fall between 0 and 1. 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. 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. The call to set_seriestype configures the style of the series when drawn. The index of zero is passed because Aplot uses 0-indexing for its series identification. ![]() In this case, since we’ll be showing 1000 points, we’ve asked for it to be drawn as a scatter plot using single pixels the user can also use larger dots, lines, or bars to represent a series. The second call to set_serieslabel provides a label for this series in the legend. Our second dataset, the running average, can be configured similarly: call add_dataset(plot, x, mean_y)Ĭall set_seriestype(plot, 1, APLOT_STYLE_LINE)Ĭall set_serieslabel(plot, 1, "Running Mean") #Simply fortran 2 trial series# ![]() The final step is to call: call display_plot(plot) Our plot is now entirely ready to display. Which opens a window displaying the complete plot. The final coding step is to clean up our plot after the user closes it. While not necessarily important in a standalone program, a subroutine that generates plots should always perform final cleanup before exiting. The code here should compile in Simply Fortran 2.36 without issue, generating the following on GNU/Linux: The simple code is: call destroy_plot(plot)Īfter this call, all memory associated with the plot is released, and the program can continue normally.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |