Topic: Color output (second attempt to post)

I wish to translate my output matrices (Maps of Ocean with plankton density) to color maps-- land = black, and plankton concentrations from low to high in blue to red etc  ANy ideas as to how? I understand you an do this in R but wish to do it in FORTRAN (I could  with old software),

Charles Hall chall@esf.edu

Re: Color output (second attempt to post)

Charles,

If you're asking if you can produce the color map in a window from Fortran directly, it would be possible but difficult.  With Simply Fortran for Windows, you could manually generate the color map by writing routines for AppGraphics.  However, AppGraphics is quite low-level, and you'd have some work ahead of you.

You might be able to use other plotting software, PLPlot or PGPlot, with their Fortran interfaces.

Jeff Armstrong
Approximatrix, LLC

Re: Color output (second attempt to post)

The Fortran interface to the free dislin plotting package (see http://dislin.de) includes plot options that contain maps.

Re: Color output (second attempt to post)

What is NaN and how I do I get rid of these in my numerical output? My Fortran77 program works well in Microsoft Fortran6 but when I use Simply Fortran 2.27, I get the NaN in my computational output (in some grid points especially at boundaries).

Re: Color output (second attempt to post)

NaN is "Not a Number," and usually results from illegal math operations.  Is there any reason you're using such an old version of Simply Fortran?

Jeff Armstrong
Approximatrix, LLC

Re: Color output (second attempt to post)

to baf1

Thanks
I tried to download dislin but failed to make any useful progress.   I opened the downloads page and got a series of files that might be useful  but sort of overwhelming.  SO I tried to download the first one but was not sure where to put it or how to use it. 

Have you done this and plotted from your FORTRAN? Can you send me a simple example, either here or at chall@esf.edu ??

Is there any way to simply print out different colors to an output file directly from a write statement? 
THank you Charlie

Re: Color output (second attempt to post)

Charles,
I think creating a color map with AppGraphics might be quite simple.
First select  red-green-blue (RGB) color palette
(for nice examples see e.g. http://www.gnuplotting.org/tag/colormap/).
Then  translate your data point to color (r,g,b triple) and then to a single integer
using
    icol = creatergb(r,g,b).
Now set color using
   call setcolor(icol)
and plot colored rectangle using
   call bar(left, top,right, bottom).
I did not test it but it should work. Of course, you can save your colors to a text ile
as a (r,g,b) triples. In order to see how plotting in AppGraphics works, refer to the
Game of Life example.
Best,
Carlos

Re: Color output (second attempt to post)

Thanks Carlos
Looks like what I am looking for !   OK I guess I have to get AppGraphics going.   Last time I tried I failed, but maybe I can do it now...

Charlie

Re: Color output (second attempt to post)

I wrote this before but apparently did not save it properly.

Carlos/Jeff/whomever   

I did this and it "worked" (?)


SubRoutine Color
  use appgraphics
   integer::window
    window = initwindow(800, 600, title="Example Application")


With this I got no compile errors and a color (I think) image flashed on my screen
And the main program completed.

All of the stuff below (except declares)  would not compile at all.   
       
I would like it to stay put on my screen, or ideally write to a file.  Then I would like to plot a matrix.  I fell I am close but do not know what to do next.
    !    #include <appgraphics.h>     

!      CHARACTER :: splot
!      INTEGER :: MAP

   !     set view map
    !!  set dgrid3d 200,200,2
    !  splot "sand_density1.txt" u 2:3:5
     
  !     setfillstyle(SOLID_FILL, RED)
!      bar(10, 10, 160, 110)

!      setfillstyle(SOLID_FILL, BLUE)
  !     fillellipse(85, 60, 75, 50)


None of the above would compile with either use or include the above packages  with or without various attempts to declare variables.

Charlie

10 (edited by Carlos Herrera 2019-12-26 10:30:07)

Re: Color output (second attempt to post)

Charles,
I have noticed that you mix gnuplot and C commands with fortran syntax. I suggest that you start
with something simpler and learn the fundamentals of modern fortran using tutorial for
beginners, see e.g http://fortranwiki.org/fortran/show/Tutorials.
In the meantime, you may try the minimal appgraphics program:
---
program main
    use appgraphics
    implicit none
    integer :: main_win, icol
    main_win = initwindow(800, 600, closeflag=.TRUE.)
    icol = creatergb (0, 125, 255)
    call setfillstyle(SOLID_FILL, icol)
    call bar(100,100,200,200)
    call loop()
    call closewindow(main_win)
end program main

Re: Color output (second attempt to post)

If you want to use Simply Fortran with Dislin, the easiest way is to pay for the SF package manager that is available, as they have dislin already to to, integrated into SF (see http://packages.simplyfortran.com/account/new.html).  Then go to the dislin website and look at the online manual section on mapping (http://www2.mps.mpg.de/dislin/kap13.html) that gives some examples.


http://packages.simplyfortran.com/account/new.html

chall wrote:

to baf1

Thanks
I tried to download dislin but failed to make any useful progress.   I opened the downloads page and got a series of files that might be useful  but sort of overwhelming.  SO I tried to download the first one but was not sure where to put it or how to use it. 

Have you done this and plotted from your FORTRAN? Can you send me a simple example, either here or at chall@esf.edu ??

Is there any way to simply print out different colors to an output file directly from a write statement? 
THank you Charlie