forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Native %pl

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4689
Location: Salford, UK

PostPosted: Thu Apr 20, 2017 4:03 pm    Post subject: Native %pl Reply with quote

A new set of DLLs is now available for download from here...

https://www.dropbox.com/s/0qw4u3uszhqif7g/newDLLs7.zip?dl=0
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 454

PostPosted: Fri Apr 21, 2017 12:36 am    Post subject: Reply with quote

ooer missus ... that's now x3 posts with the title 'Native %PL' !!!
Mr Confusion will be knocking before long ! Smile
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 1433
Location: South Pole, Antarctica

PostPosted: Fri Apr 21, 2017 6:54 am    Post subject: Reply with quote

Thanks Paul. The simpleplot_update@ (though the name sounds irrelevant) now works. As I wrote the linear plotting looks almost ideal now, here how it looks in comparison with the leading scientific software OriginLab

Antialiasing makes curves look better then anything on the market now.
The only what needs fixing is numbering (Y scale has also problems, like number 1e22 instead of 100 or at least 1e2) and sometimes plotting gets out of plotting region (see the same below for LOG scales),
axis captions are better put centered by default -- and it is completely done

The source for this comparison is here. All may use own data or I can send mine for exact comparison (does this code work with you under last DLL7 ?)
Code:
 winapp
USE clrwin
integer, parameter :: n_dim = 1153
real*8 xstart, 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
xstart=0 ! 12 !

      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


And now LOG scale plots start to approach usable shape. Log scales are kind of more important to get fixed because without them 3/4 of all %pl cases (linear, log_linear, linear_log, log_log) will not work

Couple of problems with the DLLs7
1) small typo in the readme The source written there does not work because the line USE CLRWIN must go inside the module MODD
2) This code crash if use accelerator Ctrl+Z. Same for the code demo in the README (or see similar code below which crashes in my case)
3) The code for the linear Native pl Linear scale above works with DLLs6 but does not compile with DLLs7.


Last edited by DanRRight on Fri Apr 21, 2017 10:25 pm; edited 7 times in total
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 1433
Location: South Pole, Antarctica

PostPosted: Fri Apr 21, 2017 7:09 am    Post subject: Reply with quote

continue

DLLs7 still crash my main code and SDBG64 in few circumstances so I still need to get back to older DLLs5. If this is not my problems and the users will also see the same crashing problems may be we will need to update the entire compiler. I may even give you to play my code so that the bugs will be found and fixed much faster not taking time of developers from more important things.

Now about LOG scale plotting. It looks now MUCH better, everyone can see that on this example I further modified from README file
Code:
   WINAPP
   MODULE modd
   USE clrwin
   INTEGER,PARAMETER::N=25
   REAL*8 X(N),Y(N),Z(N),T(N)
   !.....................................
   CONTAINS
   !.....................................
   INTEGER FUNCTION callb()
   REAL(2) random
   DO i=1,N
     X(i)=i
     Y(i)=exp(1.*i) * random()
     Z(i)=exp(2.*i) * random()
     T(i)=exp(3.*i) * (random()-0.003)
   ENDDO
   CALL SIMPLEPLOT_REDRAW@
   callb = 2
   END FUNCTION
   END MODULE

   !.....................................
   PROGRAM JJJ
   USE modd

   j=callb()
   i=winio@('%ww&')
   CALL winop@("%pl[native]")
   CALL winop@('%pl[title="Native pl Log_linear"]')
   CALL winop@("%pl[x_array]")
   CALL winop@("%pl[scale=log_linear]")
   CALL winop@("%pl[y_min=100.0]")
   CALL winop@("%pl[y_max=1e7]")

   call winop@("%pl[framed]")
   CALL winop@("%pl[tick_len=10]")
   CALL winop@("%pl[axes_pen=3]")
   CALL winop@("%pl[x_axis='Wavelength (A)']")
   CALL winop@("%pl[y_axis='Intensity (arb.units)@(-5.0)']")

!  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=2]")
   CALL winop@("%pl[colour=red,link=none,symbol=7]")
   CALL winop@("%pl[colour=blue,link=none,symbol=8]")
   CALL winop@("%pl[colour=green]")
   i=winio@('%pl&', 800,600, N, X,Y,Z,T) 
   i=winio@('%ac[Ctrl+Z]&',callb)
   i=winio@('%sf%ts&', 1.d0)
   i=winio@('%ff%cn%^bt[Redraw]%es',callb)
   END

Few defects are
1) plotting curves outside the box (symbols are plotted OK)
2) after clicking on Redraw 4-5 times it will switch on linear scale because I specifically made T numbers negative. Besides the fact that native %pl should not switch on linear scale as "y_min=100" condition is used this also wrecks chaos in linear plotting
3) somewhere in the ℅pl internals the real*4 numbers are still used because it is impossible to increase array size beyond N=30 which means exp(3*30)>1e38


Reason why I pay such attention to developing easy scientific graphics plotting utilities in Fortran is because I'm 100℅ convinced that without them Fortran is dead. It will be swallowed by MATLAB. Each student of technical universities now uses MATLAB. Adoption of Fortran is 1000x less. What is the reason for such crazy discrepancy? Both are simple, even similar in syntax and Fortran is even faster. The answer is that Matlab just made super easy professional graphics and math libraries, they are like ultimate easiest Lego blocks. Look at the MATLAB samples I cited few days back in another ℅pl thtead. Even the plot of 3D data can be done typing just a dozen symbols.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4689
Location: Salford, UK

PostPosted: Sat Apr 22, 2017 7:07 am    Post subject: Reply with quote

Dan

What would you suggest that %pl does when calculating log10(y) and it finds that the supplied y is not positive? Maybe such values could be ignored (filtered out) but would that be helpful?
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 1433
Location: South Pole, Antarctica

PostPosted: Sat Apr 22, 2017 5:03 pm    Post subject: Reply with quote

Paul,
I'd experiment with these options first. If do not set y_min=positiveVal then I'd leave things as they are now, i.e. switching on linear scale plotting. Same with y_min was set as negativeVal or zero. If y_min was set as positiveVal then I'd treat negative y point as tiny positive number say 1d-200. That might help the algorithm to do smoothing better than just ignoring the negative point.

Formally 1d-200 is not even needed to be that small. Visually it will be hard to distunguush two plots one with 1d-200 and another with some number smaller then minimum plotted value by just 4-5 orders of magnutude. That may help smoothing algorithm even more.

By the way among all smoothing algorithms I like in Originlab software so called B-spline as the most stable and kind of universal due to that. It works much more reasonable than Bezier or Spline and almost never makes artifacts. I do not know how it works though, it always was no time to investigate. Ideal in this case would be to have variable degree of smoothing from straight lines to spline at your wish. May be someone here can develop such single universal function, I always wanted to have that.

After all that it would be good to add to pop-up window which informs about switching from logarithmic to linear scale that ℅pl[ y_min=Val ] can prevent the switching
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4689
Location: Salford, UK

PostPosted: Mon Apr 24, 2017 6:50 am    Post subject: Reply with quote

Thank you. I will see what can be done.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group