Silverfrost Forums

Welcome to our forums

Failure of %pl[native] options frame, framed and etched

3 Dec 2020 3:04 (Edited: 4 Dec 2020 12:24) #26697

Paul, one for you to look at when you have the chance. In this example, the specific combination of 11 data points with x values running from -10 to 0 causes the %pl option frame to fail. The left-hand vertical frame element is not drawn. This also happens with the alternative options framed and etched.

module example
use clrwin
implicit none
integer, parameter :: dp = kind(1.d0)
integer,parameter  :: npts = 11
real(kind=dp)      :: x(1:npts) = 0.d0, y(1:npts) = 0.d0, a(1:3) = (/0.d0,0.d0,1.d0/)
real(kind=dp)      :: xmin = -10.d0, xmax = 0.d0

contains

  integer function gui()
  integer :: iw
    iw = winio@('%mn[Exit]&','exit')
    iw = winio@('%bg&',rgb@(250,250,250))
    iw = winio@('%2.1ob&')
    iw = winio@('%nl y = c*x^2 + b*x + a&')
    iw = winio@('%2nlxmin%ta%`bg[white]%8rf%2nlxmax%ta%`bg[white]%8rf&',xmin,xmax)
    iw = winio@('%2nla%ta%`bg[white]%8rf%2nlb%ta%`bg[white]%8rf%2nlc%ta%`bg[white]%8rf&',a(1),a(2),a(3))
    iw = winio@('%2nl%cn%^bb[Update plot]%cb&',plot_cb)
    call winop@('%pl[native,x_array,frame,link=curves,colour=blue,width=2,gridlines,symbol=13]')
    iw = winio@('%pl&',600,400,npts,x,y)
    iw = winio@('%cb')
    gui = 2
  end function gui

  integer function plot_cb()
  integer i
  integer :: iw
  real(kind=dp) inc
    if (xmax .le. xmin) then      ! ERROR
        iw = winio@('XMAX must be greater than XMIN%2nl%cn%bb[OK]')
        x = 0.d0 ; y = 0.d0 ; call SIMPLEPLOT_REDRAW@() ; plot_cb =2 ; return
    else                          ! NORMAL
        inc = (xmax - xmin)/dble(npts-1)
        x(1) = xmin
        do i = 2, npts, 1
          x(i) = x(i-1) + inc
        end do
        do i = 1,npts, 1
          y(i) = a(1) + x(i)*a(2) + x(i)*x(i)*a(3)
          !! print*, i, x(i), y(i)
        end do
        call SIMPLEPLOT_REDRAW@()
    end if
    plot_cb = 2
  end function plot_cb
end module example

program main
use example
i = gui()
end program main

PS There are other combinations of XMIN, XMAX, and NPTS which have this issue. XMAX = 0 is common to all of these.

&','exit') iw = winio@('%bg&',rgb@(250,250,250)) iw = winio@('%2.1ob&') iw = winio@('%nl y = cx^2 + bx + a&') iw = winio@('%2nlxmin%ta%bg[white]%8rf%2nlxmax%ta%bg[white]%8rf&',xmin,xmax) iw = winio@('%2nla%ta%bg[white]%8rf%2nlb%ta%bg[white]%8rf%2nlc%ta%`bg[white]%8rf&',a(1),a(2),a(3)) iw = winio@('%2nl%cn%^bb[Update plot]%cb&',plot_cb) call winop@('%pl[native,x_array,frame,link=curves,colour=blue,width=2,gridlines,symbol=13]') iw = winio@('%pl&',600,400,npts,x,y) iw = winio@('%cb') gui = 2 end function gui

  integer function plot_cb()
  integer i
  integer :: iw
  real(kind=dp) inc
    if (xmax .le. xmin) then      ! ERROR
        iw = winio@('XMAX must be greater than XMIN%2nl%cn%bb[OK]')
        x = 0.d0 ; y = 0.d0 ; call SIMPLEPLOT_REDRAW@() ; plot_cb =2 ; return
    else                          ! NORMAL
        inc = (xmax - xmin)/dble(npts-1)
        x(1) = xmin
        do i = 2, npts, 1
          x(i) = x(i-1) + inc
        end do
        do i = 1,npts, 1
          y(i) = a(1) + x(i)*a(2) + x(i)*x(i)*a(3)
          !! print*, i, x(i), y(i)
        end do
        call SIMPLEPLOT_REDRAW@()
    end if
    plot_cb = 2
  end function plot_cb
end module example

program main
use example
i = gui()
end program main

PS There are other combinations of XMIN, XMAX, and NPTS which have this issue. XMAX = 0 is common to all of these. [quote:544ef65924]NPTS = 2, XMIN = -10, XMAX = 0 NPTS = 3, XMIN = -10, XMAX = 0 NPTS = 5, XMIN = -10, XMAX = 0 NPTS = 6, XMIN = -10, XMAX = 0 NPTS = 9, XMIN = -10, XMAX = 0 NPTS = 11, XMIN = -10, XMAX = 0 NPTS = 17, XMIN = -10, XMAX = 0 NPTS = 21, XMIN = -10, XMAX = 0 NPTS = 2, XMIN = -10.1, XMAX = 0 NPTS = 3, XMIN = -10.1, XMAX = 0 NPTS = 19, XMIN = -10.1, XMAX = 0

3 Dec 2020 3:57 #26698

Ken

Thanks. I have noted this.

9 Apr 2021 11:04 #27460

Ken

I have had a look at this. Changing the limits seems to work apart from the particular case xmin = -10 where the frame is not complete unless you reduce xmin a fraction.

I am not sure that I can safely make any changes that will improve this.

10 Apr 2021 11:30 #27474

Paul,

I had forgotten about this one, so I guess problematic data sets don't occur that often. The solution is straightforward, draw the frame via the %pl call back - I've been using that trick recently to enhance the appearance of the plot (different colours for the frame).

Please login to reply.