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 

Options for lines smoothing in %pl

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



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

PostPosted: Fri Jun 28, 2019 4:11 pm    Post subject: Options for lines smoothing in %pl Reply with quote

Please remind me which option of native %pl removes smoothing mechanism in %pl and allows just simple straight line connection of points while plotting. Could not find it including searching by keyword 'smoothing' etc, all i find is related to the tricks to smooth line pixelation. Clearly i'm bad at English synonyms. And so many options.

Seems the default smoothing of lines (like besiers do) which is substituting linear interpolation with quadratic and third order curves in LOG scale causes visible artifacts on sharp plotting function changes. Probably would be good to add in the future some arbitrary order line smoothing in %pl
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Jun 28, 2019 5:31 pm    Post subject: Reply with quote

If I open ftn95.chm and search for "smoothing", it's the first topic that comes up.

[smoothing=dval] Specifies the smoothing mode,where dval is in the range 0 to 5 . (default 0, 4 and 5 provide for anti-aliasing).

These are the same values as for %gr and SET_SMOOTHING_MODE@ etc..

SmoothingModeDefault = 0 (no smoothing)
SmoothingModeHighSpeed = 1 (no smoothing)
SmoothingModeHighQuality = 2 (8x4 box filter)
SmoothingModeNone = 3 (no smoothing)
SmoothingModeAntiAlias8x4 = 4 (8x4 box filter)
SmoothingModeAntiAlias8x8 = 5 (8x8 box filter)
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Fri Jun 28, 2019 9:03 pm    Post subject: Reply with quote

Thanks. I tried it but it did not do anything why i decided to ask, may be i forgot something. I had to plot some data in log_linear y-x coordinates which looked hell peaky at the edges where change was large. The peaks exceeded in value everything in the plot. I tried that smoothing=0, and it did not do anything while in the past i remember it was having substantial effect. Changing to linear plot removed that peaky behavior with absolutely no peaks visible at all. Will try again, may be my peaky data is indeed that hell peaky but suspect here could be some smoothing problems while in LOG scale...

So is this feature currently off ?
Back to top
View user's profile Send private message
DanRRight



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

PostPosted: Sun Jun 30, 2019 6:34 am    Post subject: Reply with quote

I made small demo. Unless i do something wrong, here in comparison is what generates %pl with smoothing=0 and what produces other plotting software. Left picture is what %pl gives, while at the right is the picture created with Origin software.
In %PL the "smoothing=0" clearly does not work. Usually such artifacts like on left picture are obtained when the internal plotting smoothing mechanisms fail. Just look at the last 4 XY points around X=2. The maximum value there is 2.427E-02 while %pl plots it as if it's 1. I hope smoothing=0 will be easy to fix

Here is simplest plotting software and approximately the same data (call the file "data.dat") as in the pictures above, it was just cut to fit into the posting size
Code:
   use clrwin
   parameter (N=100)
   real*8 X(N), Y(N)

   y( : )=1.e-30
   
   open(11, file='Data.dat')
   do i=1,N
    read(11,*,err=100,end=100) X(i),Y(i)
   enddo    
100 close(11)
   print*,' number of records=', i-1
   Nxy=i-1


   i=winio@('%sf%ts%bf%es&', 2d0) ! text size, boldface, ESC
   call winop@("%pl[axes_pen=3,width=3,x_axis='Radius (km)',y_axis='f(E) (arb.un.)']")  ! axis width, line width, axis names

   i=winio@('%ww%pv%pl[native,framed,x_array,scale=log_linear, y_min=1.e-3, y_max=1., smoothing=0, N_GRAPHS=1]', 768,640, Nxy, X, Y) 
   end

Data.dat:
Code:
 5.577E-01 2.965E-02
 5.777E-01 1.965E-02
 5.957E-01 1.665E-01
 6.057E-01 9.665E-02
 6.457E-01 3.665E-02
 6.607E-01 3.581E-02
 6.761E-01 7.000E-02
 6.918E-01 3.420E-02
 7.079E-01 6.685E-02
 7.244E-01 1.000E-30
 7.413E-01 3.192E-02
 7.586E-01 3.119E-02
 7.762E-01 9.145E-02
 7.943E-01 2.979E-02
 8.128E-01 5.822E-02
 8.318E-01 2.845E-02
 8.511E-01 8.340E-02
 8.710E-01 1.000E-30
 8.913E-01 2.655E-02
 9.120E-01 2.594E-02
 9.333E-01 7.606E-02
 9.550E-01 1.000E-30
 9.772E-01 2.421E-02
 1.000E+00 7.098E-02
 1.023E+00 6.937E-02
 1.047E+00 4.519E-02
 1.072E+00 2.208E-02
 1.096E+00 1.000E-30
 1.122E+00 4.217E-02
 1.148E+00 4.122E-02
 1.175E+00 2.014E-02
 1.202E+00 1.968E-02
 1.230E+00 3.846E-02
 1.259E+00 1.879E-02
 1.288E+00 1.000E-30
 1.318E+00 7.180E-02
 1.349E+00 5.262E-02
 1.380E+00 1.714E-02
 1.413E+00 1.000E-30
 1.445E+00 3.274E-02
 1.479E+00 4.799E-02
 1.514E+00 1.563E-02
 1.549E+00 1.000E-30
 1.585E+00 1.493E-02
 1.622E+00 4.377E-02
 1.660E+00 1.426E-02
 1.698E+00 1.000E-30
 1.738E+00 2.723E-02
 1.778E+00 1.000E-30
 1.820E+00 1.300E-02
 1.862E+00 1.000E-30
 1.905E+00 1.000E-30
 1.950E+00 2.427E-02
 1.995E+00 1.186E-02
 2.042E+00 1.000E-30
 4.042E+00 1.000E-30 


Last edited by DanRRight on Sun Jun 30, 2019 10:13 am; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sun Jun 30, 2019 10:10 am    Post subject: Reply with quote

"Smoothing" in this context determines what lines look like (anti-aliasing).

The way that data points are joined is determined by [link=lines] or "curves" or "none".

In this case it is also useful to use [symbol=val] to see the data points.

The best you can do with %pl for these data points is to use [link=lines] rather than "curves" which is the default.
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Sun Jun 30, 2019 10:34 am    Post subject: Reply with quote

Yes, this is how no line smoothing (simple straight line connection of points, or linear interpolation) was called: "link=lines" ! Unfortunately no word "smoothing" was used in the Help though this kind of line smoothing is more commonly used than antialiasing smoothing. Probably would be good to mention "link=lines" or "link=curves" as line smoothing (or curving smoothing, or better English synonyms) while antialiasing as jaggedness smoothing or else. Are these good names? Entire Clearwin becomes impossible to keep in the head, and computer search should be more helpful.

Meantime, the problem is solved, thanks, Paul. Out of two things associated with the line smoothing the less commonly used one - antialiasing - got way larger attention in the Help. Hopefully in the future the number of line smoothing (curving) options will grow and this will be easier to find in the Help (histogram, Spline, B-spline, Bezier, 2-point segment, 3-point segment, Step Horizontal, Step Vertical, Step Center). As a suggestion, if this will be also possible to change dynamically without changing source code that would be great.

As an another suggestion, may be good to the "link=lines" add also synonym "link=straight". And if add to %PL couple small cosmetic touches
- increase default minor tics length (and making them changeable like major tics)
- move Y axis name to safer distance from numbers (computer easily can center it on the left plot margin)
- increase distance between numbers and tics

the plot above will be almost perfect !
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Wed Jul 03, 2019 12:18 am    Post subject: Reply with quote

Also could be added:
- to get the darn tic labels correctly centred on the tics (that really bugs me)
- make sure xponents don't encroach into the tics 'space'
- plot 10^0 and not 1 (see left hand graph above


As for the incorrect (?) interpolation to get 'smooth' curves - what algorithm is used Paul ?

Dan I think you're a victim of your peaky data as regards the strange plot.
You're not going to see any smoothness anyway !

Mind you, even if the interpolation is different (on left graph) the resulting lines shouldn't go off the graphic !!!
The scale should be adjusted to cater for not just raw data values but also interpolated values.
We've seen this in other plots.
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Jul 03, 2019 7:08 am    Post subject: Reply with quote

The native %pl calls the Microsoft GDI+ base functions GdipDrawCurve or GdipDrawLines. Here is the initial link...

https://docs.microsoft.com/en-us/windows/desktop/gdiplus/-gdiplus-graphics-flat
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Wed Jul 03, 2019 1:30 pm    Post subject: Reply with quote

John,
My data was very rough, so smoothing mechanism failed. But almost all plotting software will fail. Origin also produced a hell different things and one of its smoothing option even freezed and crashed software. So with %pl i took linear interpolation for now and all look not bad, the only i may wish more is histogram-style plotting. But i will probably instead take bullet-style plotting and it may look even better. I showed that before in this newsgroup, i think the result looked stunning (without such niceties sometimes programming becomes a boring hell )

Smarter interpolation methods in the future may do like you suggest - they have to compare the result of smoothing with raw data with linear interpolation and adjust. Another cool smoothing program i saw when plotting different graphs interpolated not only the lines and jagg of lines but also transition from one line to another (a la "soap opera effect" all modern TVs are doing interpolating between frames Smile ). No, i don't suggest SF to do that.
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sat Jul 06, 2019 9:22 am    Post subject: Reply with quote

Dan, you wrote:
Quote:
My data was very rough, so smoothing mechanism failed


... not at all 'failed' - if you look at the plots, all the 'peaks' have lines which are almost parallel. Interčpolating those will bring you (almost) to infinity, so little surprise the values are so high.

There is of courswe in reality a 'real' peak' but impossible to say where without more data.

This occurs a lot in structural random vibration plots (we always plot in straight lines but in critical cases need to estimate the probable real peak.

Paul, thanks very much for that link.
Very useful except od course Microsoft being Micro$oft the documentation is tortuouslėy inter-linked.
Their specific details of the method used hasn't jumped out at me yet but I'll keep on delving
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
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