Search code examples
graphcolorsfortranoriginlab

Change graph color in Labtalk using a Fortran program


I have a Fortran program that creates a bat file which holds the commands for Origin in Labtalk. In the end Origin will show a graph with several plots. At present all plotted lines are displayed in black. Now I want to change the color of the graphs. Can anyone tell me where and which command I have to change? I think this must happen somewhere here:

     ...
     ch1=ADJUSTL(ch1)
     WRITE(ch2,'(I3)')JJY(i)
     ch2=ADJUSTL(ch2)

     WRITE(4,489)CHAR(77+i),'aX'//ch1(1:LNBLNK(ch1))//'Y'
     1//ch2(1:LNBLNK(ch2))
     enddo
 489    FORMAT(1H ,'%',A1,'=',A8,';')
     ENDIF
     FLINE='count='//NCHAR(1:LNBLNK(NCHAR))//';'
     WRITE(4,'(1A260)')FLINE
     WRITE(4,490)
 490    FORMAT(1H ,'window -n Data;',
     1/1H ,'open -w %A;',
     1/1H ,'window -r %H Data ;',
     1/1H ,'worksheet -t 1 4; worksheet -t 2 1;',
     1/1H ,'worksheet -n 1 %M;')
     do i=1,NUMB
     WRITE(4,491)i+1,CHAR(77+i)
     enddo
 491    FORMAT(1H ,'worksheet -n ',I1,' %',A1,';')
     WRITE(4,492)
 492    FORMAT(1H ,'window -i ;',
     1/1H ,'window -n plot Plot ;')
     do i=1,NUMB
     WRITE(4,493)CHAR(77+i),i+1
     enddo
 493   FORMAT(' %S=Data_%',A1,';',
     1/1H ,'set %S -x Data_%M; set %S -c ',I1,';',
     1/1H ,'layer -i %S',
     1/1H ,'set %S -w 1000;'     )      

     WRITE(4,494)
 494   FORMAT(1H ,'axis -ps x g 3;axis -ps x a 3;axis -ps x l 1;',
     1/1H ,'axis -ps y g 3;axis -ps y a 3;axis -ps y l 1;',
     1/1H ,'layer.x.grid.majorwidth=0.3;layer.x.grid.minorwidth=0.1;',
     1/1H ,'layer.x.grid.majorcolor=color(black);layer.x.grid.minor      
     1color=color(black);', 
     1/1H ,'page -o l;',
     1/1H ,'rescale;')
     CLOSE(UNIT=4)
     ...

Solution

  • From the Labtalk documentation of set:

    Syntax: set name -c value

    Set the plot line color and symbol edge color following the color palette [...]

    set %c -c 2; // set color to be red
    set %c -c 102; // set the next column on the right to be color index
    set %c -c 524390; // set the next column on the left to be color index
    

    This is actually done in your code:

     do i=1,NUMB
     WRITE(4,493)CHAR(77+i),i+1
     enddo
     493   FORMAT(' %S=Data_%',A1,';',
         1/1H ,'set %S -x Data_%M; set %S -c ',I1,';',
         1/1H ,'layer -i %S',
         1/1H ,'set %S -w 1000;'     ) 
    

    Not that you chose I1 to denote the color value. Maybe your number is >9 at some point? Could you check the resulting file?

    [Note that my answer is from the documentation only. I have no clue about Labtalk whatsoever. ]