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 

%pl[native] x/y label positions

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



Joined: 18 May 2012
Posts: 499
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Tue Aug 10, 2021 11:23 am    Post subject: %pl[native] x/y label positions Reply with quote

While I understand the existing algorithm used to determine the position of the x- and y-axis labels, for general purpose x/y plotting purposes it can result in very poor positioning of the x- and y-axis labels. The code below demonstrates the issue.

While this can be fixed by the programmer via a call back function to draw the labels after the %pl is drawn, a better approach (particularly for those starting to use %pl) would be an additional %pl option, with disables the default mechanism for label positioning and simply places the x-axis label centered on the centre line of the %pl frame and similarly for the y-axis label (similar to excel for example).

This would enhance the overall appeal of %pl for new users, and in my case, allow the simplification of new code.

This is the only remaining issue with the %pl[native] which I seem to run up against on a fairly regular basis.

Perhaps this proposed new option could be considered for a future update?

The direct link to the Clearwin+ enhancements file in the most recent version of Plato was a very good idea. I am finding that very useful.

Code:
module m
use clrwin
implicit none
real*8 :: x(2) = [-1.d0,1.d0],y(2) = [1.d0,-1.d0]
contains

  integer function gui()
  integer i
  i = winio@('%mn[Exit]&','Exit')
  i = winio@('Press Forward button 40 times observing position of x and y label&')
  call winop@('%pl[native,x_array,x_axis="x_data",y_axis="y_data", gridlines,frame,colour=blue,width=2]')
  i = winio@('%nl%fn[Consolas]%pl&',500,500,2,x,y)
  i = winio@('%sf%^bt[Forward]&',  forward)
  i = winio@('%^bt[Backward]&', backward)
  i = winio@(' ')
  gui = 2
  end function gui

  integer function forward()
    x(2) = x(2) - 0.05d0 + epsilon(1.0)
    y(2) = y(2) + 0.1d0  + epsilon(1.0)
    call simpleplot_redraw@()
    forward = 2
  end function forward

  integer function backward()
    x(2) = x(2) + 0.05d0 + epsilon(1.0)
    y(2) = y(2) - 0.1d0  + epsilon(1.0)
    call simpleplot_redraw@()
    backward = 2
  end function backward

end module m

program main
use m, only : gui
implicit none
integer i
i =gui()
end program main
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Wed Aug 11, 2021 7:30 am    Post subject: Reply with quote

Ken

Thanks for the feedback. I think that this is simply a bug that needs fixing.

I have logged it for investigation.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Thu Aug 12, 2021 11:24 am    Post subject: Reply with quote

Ken

I now think that a new option is needed otherwise a change will adversely affect existing code.

In future a y-axis caption that starts with a tilde will be centred on the whole y range. The tilde will not be displayed. This will be experimental until you confirm that it works to your satisfaction.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 499
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Thu Aug 12, 2021 3:30 pm    Post subject: Reply with quote

Thank you Paul, I shall lookout for the next intermediate dlls.
Have you included the x_axis? It is also sometimes poorly positioned, as shown in the example code, but not to the same extent as the y_axis.
Ken
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Thu Aug 12, 2021 4:38 pm    Post subject: Reply with quote

Ken

I will add the same option for the x-axis caption.
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Thu Aug 12, 2021 5:10 pm    Post subject: Reply with quote

I do not think this will break any code because this was just the bug from the beginning. So i suggest not to use tilde. We are all early users of this option, there are just few of us, so we will adjust if needed. Adding tilde is counterintuitive and will break more code in the future

Besides, here is another example of bad placement of caption. It has also other defect you just fixed for the new release so ignore it (i guess, because did not have this new release yet), i just found this older demo as an example. My opinion the placement of caption has to be based on centering along the entire length of the visual axis line (i mean its visual (ix,iy) pixel position). Currently position seems decided by %PL based on data min and data max and if you change y_min manually like i did below the %PL does not see it


Code:
   module mod1
   use clrwin
   parameter (N=5)
   real*8 X(N), Y(N)
   Data X/1e1, 1e2, 1e3,  1e4, 4e5/
   Data Y/2.2, 66, 8333, 1111, 777/
   save
   contains

   INTEGER FUNCTION redraw ()
!    CALL simpleplot_redraw@()
    CALL        plot_redraw@()
    redraw = 2
    end function redraw
   end module
!................................
   Program bug333
   use mod1

   i=winio@('%fn[Tahoma]%bf%ts&',2.d0)
   CALL winop@("%pl[gridlines]")
   call winop@("%pl[axes_pen=2,frame_pen=2,width=2,x_axis='X Axis Title',y_axis='Y Axis Title']")
   i=winio@('%ww%pv%pl[native,framed,x_array,scale=log_log,N_GRAPHS=1,y_min=100.]%ff&', 925,700, n, X, Y)
   i=winio@('%sf%cn%^bt[Redraw]&', Redraw)
   i=winio@('%es')
   end
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Thu Aug 12, 2021 7:05 pm    Post subject: Reply with quote

Dan

The current default is to place the y-axis caption at the centre of the positive y-axis. For me, and perhaps the authors of many existing programs, this is best.

If I change this default then some users will be justifiably aggrieved.

Using a tilde seemed to me to be simpler than providing a new option but I am willing to be flexible on this.
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Thu Aug 12, 2021 11:55 pm    Post subject: Reply with quote

This can be used but this placement of caption (in the center of positive part) is very vulnerable to being overwritten by the numbers or by the curve. Here is standard plot which i made out of Ken's example above:

Good that positions and other settings could be adjusted if use Designer Mode, all this can done after plotting without programming, just clicking. I added into the source antialiasing and other things but this actually is not needed because can be done in Designer mode. For all other users who are interested this is the code and how plot captions could look after moving them using Designer mode:


Code:
module m
use clrwin
implicit none
real*8 :: x(2) = [-1.d0,1.d0],y(2) = [1.d0,-1.d0]
contains

  integer function gui()
  integer i
  i = winio@('Press Forward button 40 times observing position of x and y label&')
  i=winio@('%ww%fn[Tahoma]&')

  i =  winio@('%ts%bf&',1.d0) ! font size and bold-face
  i =  winio@('%`bg&',rgb@(245,250,255)) ! bluish background for plot
  call winop@("%pl[smoothing=4]") ! anti-aliasing for line smoothing
  call winop@("%pl[file=zPlotDemo_DesignerMode.set]")   
  call winop@ ("%pl[axes_pen=2.]")
  call winop@('%pl[native,x_array,x_axis="x_data",y_axis="y_data", gridlines,colour=blue,width=2]')
  i =  winio@('%nl%pv%pl&',500,500,2,x,y)
  i =  winio@('%sf%^bt[Forward]&',  forward)
  i =  winio@('%^bt[Backward]&', backward)
  i =  winio@('%es')
  gui = 2
  end function gui

  integer function forward()
    x(2) = x(2) - 0.05d0 + epsilon(1.0)
    y(2) = y(2) + 0.1d0  + epsilon(1.0)
    call simpleplot_redraw@()
    forward = 2
  end function forward

  integer function backward()
    x(2) = x(2) + 0.05d0 + epsilon(1.0)
    y(2) = y(2) - 0.1d0  + epsilon(1.0)
    call simpleplot_redraw@()
    backward = 2
  end function backward

end module m

program main
use m, only : gui
implicit none
integer i
i =gui()
end program main


But in most cases more universal is to create the frame like Ken did and place the axis names in the middle of the X and Y entire frames. Here is an example:

Here you can click 40 times or 40000 times the result will look perfect. As another confirmation for that if you click on Ken's example Forward and Backward buttons the current placement in the middle of the positive part will look extremely ugly until it will be absolutely unacceptable aesthetically, permanently moving and at some point completely disappear:


So if frame is used the placement of axis caption ideally has to be in the middle of the frame


Last edited by DanRRight on Fri Aug 13, 2021 7:54 pm; edited 5 times in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Aug 13, 2021 8:08 am    Post subject: Reply with quote

Dan

In response to your initial comment, I could add a new option [y-axis=caption] that uses a hyphen rather than the existing underscore. This would be instead of using a tilde.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 499
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Fri Aug 13, 2021 8:46 am    Post subject: Reply with quote

Dan,

I think the issue here is with older code – pre 64 bit %pl[native], i.e. 32 bit applications which used the simpleplot.dll

The %pl[native] has adopted the same convention as the earlier simpleplot.dll to avoid breaking code previously compiled as 32 bit applications which may now be recompiled as 64 bit code and consequently Paul does have to retain the current default placement however “illogical” you and I think it is.


Paul,

I was happy with the prospect of adding a tilde to override the default placement, but thinking about this a little more yesterday evening after reading the later posts, an option like axis_placement=1 or 2 where 1 is equivalent to the original simpleplot.dll (and the default value where none is specified), and 2 is “centred on frame”, or using Dans’ terminology “universal” might be more straightforward from a programmer’s perspective. The selected axis_placement option would apply to both x and y.

In my case it would be an additional option to always specify once per %pl (much the same as gridlines and frame), and there is no need to worry about adding a tilde, while protecting older applications originally 32 bit when recompiled with the 64 bit compiler.

With this “option” approach you could also include a recommendation to use axis_placement=2 for new code in the help file, which would spare new users some of the “head scratching” Dan and I have experienced over the last few years (i.e where has the axis label gone to?, or why is the label poorly positioned?).

This approach would also avoid the potentially embarrassing/rework situation where the programmer’s test data produces a satisfactory graph with the tilde omitted but a third parties data (i.e. an end user) generates a less satisfactory plot in terms of axis label placement (i.e. tilde required).

While it may be slightly more difficult to implement within the Clearwin+ code (which means claiming a little more of your time - sorry) , I think this might be a more robust solution all round.

Ken
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Fri Aug 13, 2021 10:04 am    Post subject: Reply with quote

Ken

It would be simpler, both for me to implement and perhaps also for the user, if I add new options [x-axis=name] and [y-axis=name] where the original underscore is replaced by a hyphen.

I will implement this approach on an experimental basis then you can test it and report back how you get on.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 499
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Fri Aug 13, 2021 11:02 am    Post subject: Reply with quote

Paul,

That's fine, I think I may be guilty of thinking about this a little too much.

Thanks

Ken
Back to top
View user's profile Send private message Visit poster's website
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