!______________________________________________________________________________ ! This program demonstrates how to use the Graphics module to plot 2D curves ! It plots the function y=x^2 exactly and with random deviations. ! The function Plot3D is used identically, but with x,y and z data. !______________________________________________________________________________ PROGRAM DISLIN_test USE Graphics IMPLICIT NONE INTEGER, PARAMETER :: N=10 INTEGER :: i REAL, DIMENSION(N) :: DELTA REAL, DIMENSION(N,2) :: X,Y,Z X(:,1)=REAL((/(i,i=1,N)/))/N X(:,2)=X(:,1) Y=X**2 CALL RANDOM_NUMBER(DELTA) DELTA=(DELTA-0.5)/5 Y(:,2)=Y(:,2)+DELTA ! This is an example of using Plot2D plot: CALL InitGraphics("2Dmatrix_test_plot.png","PNG",(/"Example of 2D plot","y=x^2"/),"x","y=x^2") CALL Plot2DMatrix(X,Y,"LS","|T","BR") CALL AddLegend((/"Fitted curve","Experimental points"/)) CALL EndGraphics() Z=SQRT(X) Z(:,2)=Z(:,2)+DELTA ! This is an example of using Plot3D: CALL InitGraphics("3Dmatrix_test_plot.png","PNG",(/"Example of 3D plot","","="/),"x","y=x^2","z=sqrt(x)") CALL Plot3DMatrix(X,Y,Z,"LS","|T","BR") CALL AddLegend((/"Fitted curve","Experimental points"/)) CALL EndGraphics() END PROGRAM DISLIN_test