Silverfrost Forums

Welcome to our forums

Native %pl

2 May 2017 6:12 #19537

Passed my test with slightly made up numbers.

Thanks again.

http://tr5mx.co.uk/test_0.05.jpg

4 May 2017 6:41 #19564

OK, finally good news, as of today the options of new PL allowed it to beat not only Simpleplot but the Matlab and OriginLab in visual quality of image in linear plotting. Excusing couple small grains of salt here is what new %pl shows. Compare and tell which one is better, OriginLab or Silverfrost?

https://s2.postimg.org/ml4xvtrjt/Image80.png

Now we can adjust all border sizes, the line widths and axis widths, positions of the titles and quality of smoothing. The x_min, x_max, y_min, y_max work in linear and LOG scale well. Specifically great is LOG handling of zero and negative numbers with convenient popup menu etc

So we are 99% close to be the best universal plotting routine in Fortran, congrats to Silverfrost

About LOG scale plotting will be next message as well as what is left to update and fix

4 May 2017 12:42 #19570

Paul, I am reticent to post this as you are probably a bit fed up of our collective comments by now.
A useful possible addition would be a flag which forces %pl to place the scales external to the frame, this would avoid the situation where data points obscure the numbers on the scale, and would give a more uniform appearance when groups of plots a combined together. The group of plots shown in the example below would look so much better if this was possible.

http://www.tr5mx.co.uk/scale_position.jpg

4 May 2017 1:48 #19571

OK. That might be a simple addition. Would it be for the x-axis only and what name would you suggest?

4 May 2017 3:18 #19572

Paul, I would suggest both x-and y-axis, the magnetic flux density profile plot I posted on Tuesday suffers the same issue.

Maybe something like:-

y_crosses = automatic     for current method
y_crosses = xmin          to force y axis to be drawn at the position of minimum x value

x_crosses = automatic     for current method
x_crosses = ymin          to force x axis to be drawn at the position of minimum y value

This should work with and without the frame option.

Plotting this type of data in excel has the same issue in its 'automatic' mode and the suggested names are somewhat similar to the terminology used within excel.

Another related thought looking at an excel plot, perhaps a flag to force the x and y labels to be centered on the centre lines of the frame? This would avoid setting [x-axis=@] or [y-axis=@] and having to use a call-back to centre the labels. I have noticed that at present these are always placed centred on the positive part of an axis scale and if all the data being plotted is in the 4th quadrant the y-axis label is omitted. x_label_position = 'automatic' or 'centre' and the same for the y_label_position perhaps?

5 May 2017 9:22 #19584

John, your are correct there is an endless list of possibilities depending on the programmer's personal preferences for what 'looks good' as well as the nature of the data itself. As soon as I had typed x_crosses = 'automatic' / 'xmin', the thought struck me why not include a numerical value - which would complicate the programming further. My own %gr based plotting routine which has evolved over the last 5 years now has 70+ optional arguments, and still there a other options which I would like to add for the odd occasion I might use them.

A typical call to this routine looks like this:-

              call plot(500, igw=400, igh=350, ghandle=2, etched=0, &
                   title = 'Fourier', x_axis_label = 'Time [s]', &
                   y_axis_label = 'Amplitude [pu]', &
                   x_array = x, y1_array = y1, y2_array = y2, y3_array=y3, y4_array = y4, y5_array = y5, &
                   y6_array = y6, &
                   y1_width = 2, y2_width = 2, y3_width = 2, y4_width = 2, y5_width = 2, y6_width = 2, &
                   y1_colour = rgb_deep_pink, &
                   y1_symbol = 4, y1_symbol_size = 5, y2_symbol = 1, y2_symbol_size = 2, y2_colour = rgb_cornflower, &
                   y3_symbol = 4, y3_symbol_size = 5, y3_colour = rgb_english_red , &
                   y4_symbol = 4, y4_symbol_size = 5, y4_colour = rgb_maroon, &
                   y5_colour = rgb_dark_orange, y6_colour = rgb_forest_green ,&
                   y5_symbol = 4, y5_symbol_size = 5, &
                   y6_symbol = 1, y6_symbol_size = 2, &
                   y1_symbol_step = 5, y2_symbol_step = 5, y3_symbol_step = 5, &
                   y4_symbol_step = 2, y5_symbol_step = 5, y6_symbol_step = 5, &
                   autoscale_x = .true., autoscale_y = .true., y1_name ='1', y2_name='5', y3_name='7',&
                   y4_name = '11', y5_name = '17', y6_name = 'Sum', &
                   vertical_grid_line_style = 1, horizontal_grid_line_style = 1, &
                   vertical_grid_line_width = 1, vertical_grid_line_colour = rgb_cornflower, &
                   horizontal_grid_line_width = 1, horizontal_grid_line_colour = rgb_cornflower, &
                   fmt_x_axis = '(F20.4)', fmt_y_axis = '(F20.2)', bold_title = 1, italic_title = 1, &
                   underline_title = 1)

So I am very pleased with the new %pl !

Paul, I do agree with John that grid lines would be a useful longer term addition - there have been grumblings from the guys who use my code since I started using the new %pl as they are used to seeing these.

If you can easily implement the placement of the axis scales external to the frame, and centring of the axis captions this would pretty much guarantee a uniform appearance when different %pl regions are grouped together and for me that would be a big step forward. (I'm probably harking back to the days when I taught engineering drawing - 30 years ago - pen/paper/drawing board, when consistency in appearance is all important).

Thanks

Ken

8 May 2017 7:03 (Edited: 8 May 2017 8:08) #19593

Paul,

The few grains of salt in ideal %pl i mentioned above are the following. This is what's left to fix in Linear scale, all but may be one are really fast to fix

Let's take this code which plotted almost ideal plot above

winapp
USE clrwin 
integer, parameter :: n_dim = 1153
real*8  X(n_dim), Y(n_dim) 
integer(7):: hDib ! 
integer*4 ilw
character filename*128

      i=winio@('%ww[no_border]&') 
      i=winio@('%gr[BLACK]%ff%lw&',660, 550, ilw) 

      filename = 'SpectraSampleLinear.bmp'
      hDib = import_bmp@(filename,ires)
      if(ires == 0) ires = dib_paint@(0,0,hDib,0,0)
      call release_screen_block@(hDib)

OPEN (UNIT=275,FILE='A.dat',STATUS='old',err=990)
do i=1,10000
  if(i.gt.n_dim) goto 100
  read(275,*,err=995,end=100) X(i), Y(i) 
enddo
100 close(275) 
n_points=i-1

      i=winio@('%ww[no_border]%es%ca[Default Plot]%pv&') 
      i=winio@('%fn[Tahoma]&')  ! Verdana
      i=winio@('%ts&', 1.9d0) 
      i=winio@('%tc&',rgb@(0,0,0)) 
      i=winio@('%bf&') 
      i=winio@('%`bg&',rgb@(250,255,255)) 
      CALL winop@('%pl[axes_pen=3]') 

!     CALL winop@('%pl[SCALE=LOG_LINEAR]') 

      call winop@('%pl[framed]') 
      CALL winop@('%pl[tick_len=9]') 
      CALL winop@('%pl[margin=131]') 
      call winop@('%pl[link=curves]') ! link=lines 
      CALL winop@('%pl[n_graphs=1]')    
      CALL winop@('%pl[title='Native PL Linear']') 
      CALL winop@('%pl[x_axis='Wavelength (A)']') 
      CALL winop@('%pl[y_axis='Intensity (arb.units)@(-5.0)']') 
      CALL winop@('%pl[width=2]') 
      CALL winop@('%pl[smoothing=4]') ! anti-aliasing 
      CALL winop@('%pl[colour=black,style=0,pen_style=0]')    
      CALL winop@('%pl[x_array]') 
      CALL winop@('%pl[x_min=12.0]') 
      CALL winop@('%pl[y_max=155.0]') 
      i=winio@('%pl',770,660,n_points,x,y)

goto 10000

!................. errors ......................
990 Print*, 'Error opening file A.dat for read'
goto 10000
995 Print*, 'Error reading file A.dat'
goto 10000
 
10000 continue
end

If increase image size using mouse you will see the following little problems https://s14.postimg.org/q3ipyinrl/Image114.jpg

  1. this problem is obvious
  2. Y division is too often, way too many numberings, even though the plot size is very large
  3. X division like this must never appear in ideal %PL Also a bit too many numberings here - 12. May be 12 also would be OK but it have to be integer numbers 12, 13...22
  4. This is clearly a much difficult problem: mixture of integer and FP numbers for numbering. I think it is not acceptable
  5. Like others also agree the X axis title Wavelength by default has to be centered and moved left and right only at the user request with @(x,y)
8 May 2017 7:06 (Edited: 8 May 2017 1:11) #19594

CONTINUE 1

Respect to 2) and 3) above I played with the code Ken found on the net about scales https://people.sc.fsu.edu/~jburkardt/f77_src/toms463/toms463.html and found its first two routines SCALE1 and SCALE2 are useful. Let's look specifically for our case above. If we change data in the SCALE1 case (automatically decides which amount of numbers to place within users decided region) there to

      data n_test / 7, 12, 9 /
      data xmin_test / 12., 12., 0.0 /
      data xmax_test / 22., 22., 155.0 /

we will get 	

  SCALE1 chooses a scale for a plot.
       XMIN       XMAX   N      XMINP      XMAXP       DIST Nactual
       12.0       22.0   7       12.0       22.0        2.0       5
       12.0       22.0  12       12.0       22.0        1.0      10
        0.0      155.0   9        0.0      160.0       20.0       8

where first and last case are for ideal numbering of X and Y scales. Middle case is for X scale i'd call it more verbose amount of numbers like your code is doing today.

So in automatic regime your code must decide which amount of numbers to place on axis based on font size (ideally 5-10) and then run SCALE1 and it will tell exactly what numbers will be placed and their amount. Easy fix.

You can see the SCALE1 program makes exactly ideal step for X axis equal 2, for Y it is 20

In the manual regime which shown in SCALE2 which listens exactly at users defined step (which John also suggested) there must be special option added where user in addition to the existing xmin and xmax, sets the value which TEST02 calls n_test ( better call it increment or step or else. In ideal case above for X step is equal 2, for Y it is 20). Then the user will be responsible for all the garbage he requested 😃. Also an easy fix !

And the last is that if tic mark is not numbered like some on X axis the tic length has to be reduced, say, by 40-50%

And the ideal linear scale %pl is done!

8 May 2017 10:15 (Edited: 8 May 2017 1:11) #19595

CONTINUE 2 With LOG all fixable probably even faster

Let's take this code

   WINAPP 
    MODULE modd 
    USE clrwin 
    INTEGER,PARAMETER::N=65 
    REAL*8 X(N),Y(N),Z(N),T(N), U(N) 
    !..................................... 
    CONTAINS 
    !..................................... 
    INTEGER FUNCTION callb() 
    REAL(2) random 
    DO i=1,N 
      X(i)=i 
      Y(i)=exp(0.35*i) * random() 
      T(i)=Y(i)      
      Z(i)=exp(0.7*i) * (random()-0.003) 
      U(i)=Z(i)
    ENDDO 
    CALL SIMPLEPLOT_REDRAW@ 
    callb = 2 
    END FUNCTION 
    END MODULE 

    !..................................... 
    PROGRAM KKK
    USE modd 

    j=callb() 
    i=winio@('%ww&') 
    CALL winop@('%pl[native]') 
!    CALL winop@('%pl[title='Log_linear@(115,299)']') 
    CALL winop@('%pl[title='Title: ideal log_linear@(-15,10)']') 
    CALL winop@('%pl[x_array]') 
    CALL winop@('%pl[scale=log_linear]') 
    CALL winop@('%pl[y_min=.3]') 
    CALL winop@('%pl[y_max=1e7]') 
    CALL winop@('%pl[N_GRAPHS=4]') 
    call winop@('%pl[framed]') 
    CALL winop@('%pl[tick_len=10]') 
    CALL winop@('%pl[axes_pen=4]') 
    CALL winop@('%pl[x_axis='Wavelength (A)@(-202,2)']')
    CALL winop@('%pl[y_axis='Intensity (arb.units)@(-20,-222)']') 

 !  i=winio@('%fn[Tahoma]&')  ! Verdana 
    i=winio@('%sf&') 
    i=winio@('%ts&', 2.2d0) 
    i=winio@('%tc&',rgb@(0,0,0)) 
    i=winio@('%bf&') 

    CALL winop@('%pl[width=3]') 
    CALL winop@('%pl[colour=red,link=none,symbol=7]') 
    CALL winop@('%pl[colour=blue,link=none,symbol=9]') 
    CALL winop@('%pl[symbol_size=8.]')
    CALL winop@('%pl[colour=black]') 
    CALL winop@('%pl[colour=green]') 
    i=winio@('%pv%pl&', 700,570, N, X,Y,Z,T,U)  
    i=winio@('%ac[Ctrl+Z]&',callb) 
    i=winio@('%sf%ts&', 1.d0) 
    i=winio@('%ff%cn%^bt[Redraw]%es',callb) 
    END

It now looks like this https://s24.postimg.org/dj3667snp/Log_Linear_Now.png

Obvious small problems https://s13.postimg.org/cvhlb6trb/Log_Linear_Now2.png

  1. obvious out or plotting area at the top and bottom
  2. numbering has to be a bit different, not from 0.3 to 3, 30 etc but from 1 to 10, 100 etc like here which I photoshopped

https://s11.postimg.org/e0il6lkgj/Log_lin_hastobe.png

  1. X tics being plotted inside and outside easy to fix. Ideally adding an option tics_in, tics_out, tics_inout like in Origin

  2. minor tics do not scale right with major (longer) tics if resize them. Minor tics have to follow major tics, just always being 40-50% smaller

  3. Making parameter N>90 crashes code with message of 'argument to EXP out of range'. Exp(90) should be perfectly OK with REAL*8 numbers

  4. Message offering switch to LINEAR scale from LOG has to react on Esc (Esc means no switch to linear in this case)

  5. Attempt to resize window after launch messing up everything. After Redraw all works fine

  1. Y caption horizontal position jumps widely when hit Redraw

LOG scale DONE!

8 May 2017 11:01 (Edited: 3 Jun 2017 4:16) #19597

CONTINUE 3

Here is another, may be better, or at least much more common option for numbering of major LOG tic marks. It looks more homogeneous and easier to implement. (The minor tics choice though does not look good, the %pl existing tics are better)

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4557088/bin/srep13436-f7.jpg

  1. Again, X axis name 'Wavelength' like in LINEAR case has to be centered by default. Right justified or moved somewhere has to be user's additional business if needed.

  2. 'Simpleplot_update' name has to be exterminated from the compiler ! This should be changed to Plot_update@(handle) which changes only the plot marked with specific handle or all open plots if handle is not set or negative

All that will make native %pl 99.9% ideal plotter.

The rest 0.1% can be added later. Some of these ~0.1% I implemented in my own graphics routines and I can share the experience and source code, often just few dozen lines of FTN95 Fortran. Mostly they are like 5 minutes to implement for programmers like Paul still they add WOW factor to the plot and leave all other real time graphics programs light years behind.

For example

  • changing symbol size and color according to the Y or X value like in the plots few days back (the ones with the color bar)
  • saving graphics into the PNG file PlotYYYYMMDD_hhmmss_ss.PNG and also clipboard
  • adding mentioned before grid lines, color bar
  • adding error bars (in the form of two numbers (a,b) which are for (+%,-%) from given Y point
  • adding Settings menu
  • adding move of everything with just Ctrl+mouse (i made that for all axis positions, it's very nice - all using this Fortran)
  • adding boxes with the names for curves and symbols like in Crossection vs Deuteron Energy plot above posted few days back. Ability to use Greek letters, subscripts and superscripts
  • adding graphics background (also easy to do in Fortran, see below)
  • adding shadows to the lines, axis and tic marks
  • making fill under the plot, like here

https://s29.postimg.org/wea3m3g5z/Ideal_PL.png

All that will still make 99.99% of ideal

AND the rest 0.01% would be adding an option of keeping all plotting proportions when the user scales the plot size by means of %pv

13 May 2017 11:29 #19627

CONTINUE 4

Respect to color background used in the last example above, it was so easy to do and was so reliable in FTN77/95 that I made it and forgot for decades. Actually all is done in 5-6 lines of Fortran code after you loaded graphics background tiles. I have demo for it but it is larger then one or two post pages (too harsh restriction), because I also made a GUI and plotted some besier graphics on top. PM me and i will email it to you. Here is just the sketch for this, the rest anyone can do themselves.

1) count BMP files which will be used used as the graphics backgrounds (tiles). Note that ATTR_files, date_files, time_files are wacky size integer**2 which I always forget and make a mistake, though there may already exist more normal utility as we discussed that here few times

	numbBkgFilesRealyExist = 0
        filePAT = '*.bmp'
        call files@ (filepat, numbBkgFilesRealyExist,  numbBkgFiles, FileNameBkgBMP, ATTR_files, date_files, time_files, file_size)

2) then find their XY sizes and number of colors

       do i = 1, numbBkgFilesRealyExist
         file  = FileNameBkgBMP(i)
         call get_dib_size@(file, ixBkgBMPsize(i), iyBkgBMPsize(i), inb_colours, ier)
         ihDibBkgFile(i) = import_bmp@(file, ires)
       enddo

3) find the XY dimension of the graph where these tiles will be used

        call get_graphical_resolution@(ixGrsize, iyGrsize)

4) and plot background over which you then plot your graphics. The icurBkgDispl is current choice of one of the graphics backgrounds

        do ivert =1, iyGrsize/iyBkgBMPsize(icurBkgDispl)+1
          do ihoriz=1, ixGrsize/ixBkgBMPsize(icurBkgDispl)+1
            i = dib_paint@((ihoriz-1)*ixBkgBMPsize(icurBkgDispl), (ivert-1)*iyBkgBMPsize(icurBkgDispl), ihDibBkgFile(icurBkgDispl), 0, 0) 
          enddo
        enddo
21 May 2017 5:42 #19650

CONTINUE 5

And the final point over i to the native %pl would be adding elements of visual Clearwin+ (which supposedly existed but I never have seen a single example of it. Is it still working and supported ? Pity of not, because this would change the mass perception of Fortran capabilities).

Currently all assembling of the plot has beed done purely by scripting/programming. Nice that adding %pv we can scale the size of the plot with the mouse, but we need more then that. Would be great to add the functionality when the user by pushing some control key like Ctrl or doubleclick can move axis and caption positions etc using his mouse (and possibly the arrow keys on the keyboard) as well as by clicking on the graph call and change all other properties of the plot.

If for example axis margins are set as variables @(ipos, jpos) instead of strict numbers @(33,4) these variables can be saved and used next time. This will make new %pl finally IDEAL tool no one ever had. This is how Fortran must operate. Instead it is currently purely suicidal scripting language leaving the major its advantage - almost natural syntax and almost ultimate simplicity (MATLAB language is Fortran-like and it is currently a simplicity and functionality king, if not yet, it definitely will. Because sadly at some point some morons magnetized people's common sense with the absurd claim that Fortran is just the FORmula TRANslation).

I implemented myself some of such visual functions using Clearwin graphics library in my graphics routines long ago and like this very much. Because this is ultimately exactly how it should be done in the ideal world. This is so easy to do that in comparison the correct tic numbering we are still discussing looks like a tedious job

22 May 2017 8:12 #19652

If I can add my very minor contribution, may I add to the plea for grid lines?

I often draw graphs with the same units on both axes: shear stress on one, direct stress on the other, and Excel doesn't let me set the scale the same for both. That effectively makes the grid exactly square. Excel doesn't plot graphs, but charts.

Eddie

29 May 2017 10:58 #19668

The image posted illustrates my issue precisely, because the grid lines define rectangular, not square, boxes. Thus the scales are not the same. The slope of the straight line plotted can be determined by Excel, and if you are interested in, say, y = m x + c, then ‘m’ is readily obtained, even subject to various constraints, such as c cannot be less than 0. Even if you are interested in the line as y = x tan f + c, Excel can give you f in degrees, radians or whatever you want. The issue is that unless the scales are the same, you can’t measure f with a protractor (thus making a trap for student idiots) and if the scales are very different, the visual perception of the angle f is skewed. Working in a field where f has some meaning (calm down dear, this convention was set hundreds of years ago and isn’t my fault), it isn’t a show-stopper, but it gets in the way of instant recognition when you see the printout.

You need equality of scales if, for example, Mohr’s Circle is not to appear as an ellipse.

Not that it matters for an instant when looking on a screen, but the hard copy has the additional shortcoming that the scale isn’t really rational, as in (say) 10mm represents 20 kPa (or 1 inch = 30 psi). Meaning you can’t scale off it easily.

If someone can point me to a way of getting the x and y axis scales exactly the same and rational in Excel, then I would be in their debt. As to a matter of semantics, of course it is so, and I have defined things to mean what I intend them to mean, a la Red Queen. But Excel’s charts allow you to plot things that obfuscate data relationships as easily as it can clarify them, earning from me the disparaging ‘charts’ (spat contemptuously!) appellation as against the engineer or scientist’s ‘graph’ (spoken in hushed tones with an air of approbation!). Where does this semantics come from? Probably from ‘graph paper’ usually ruled in squares.

Eddie

8 Jun 2017 8:49 #19725

John, Here is the link on my Microsoft Onedrive open account, file IdealPL.zip has data, sources and examples made in OriginLab for visual comparison with professional scientific graphics software

https://1drv.ms/u/s!Ao024Ta1-aVRhylqx47UY5Sx6W0p

Other demos are also open for everyone (excluding EXE file and PS_problem were for my own use)

9 Jun 2017 3:02 #19728

John, You can rearrange these two windows from stacking vertical to horizontal position adding just a pair of %ob/%cb for these two lines

      i=winio@('%ww[no_border]%ob&') 
      i=winio@('%gr[BLACK]%ff%cb%lw&',660, 550, ilw) 

Vertical window positioning was taken because i used large resolution 3840x2160 (4k TV as a PC monitor).

/** which i also recommend to everyone - this is way cheaper and infinitely better than any non-4k real PC large monitors in the world. Latter one because there are no PC monitors of size ~50' but this is exactly the minimum size all monitors have to have. As the owner of many top notch monitors in the past (i hated some of them despite their sometimes $3-4K price tags) i will assure that you will be stunned both with the improved quality of work and entertainment. Also, before, couple years back, only NVIDIA 900 series videocards worked with 4K monitors via HDMI ports, but today probably all work (the only condition for good text rendering is that the monitor has to support 60Hz at 4:4:4 chroma simultaneously. And if your kids play games on it then it has to have also small input lag ~25ms or less in game mode. There such good chroma bandwidth is rarely needed. Consumption is by the way only 72W in my case of 50', less then for 2-3x smaller CRT monitors).

21 Jun 2017 9:21 #19788

The 64 bit case runs OK for me. I will take a look at the 32 bit case.

21 Jun 2017 10:00 #19793

John,

  1. What are your screen dimensions? You may not see all these problems if you resize the plot but the screen size is not large enough

  2. The Silverfrost demo code you posted crashes in 32bit case too. The 64 run OK

BTW, from my quick look : what is ENUMERATOR and the code with it for?

22 Jun 2017 8:02 #19796

John

I have not looked at this yet but I think that Dan has highlighted the problem... The new ENUM feature is not working in this program for 32 bits. Try using PARAMETER instead.

24 Jun 2017 10:18 #19803

John

I don't reognise the error report and I don't have access to a PC at the moment.

For the code

ENUM,BIND(C) 
         ENUMERATOR::link_none=0,link_lines,link_curves !values 0,1,2 
         ENUMERATOR::all_graphs=0,graph1                !values 0,1 
        END ENUM 

use

INTEGER,PARAMETER::link_none=0
INTEGER,PARAMETER::link_lines=1
INTEGER,PARAMETER::link_curves=2

etc. ENUMERATOR simply provides automatic numbering of integer values.

Please login to reply.