Silverfrost Forums

Welcome to our forums

%pl[link=lines,width=1] vs. %pl[link=lines,width=3]

28 Jul 2025 2:35 #32245

In the following program two %pl graphs are used to plot identical data.

The data is an impulse function – zero everywhere but at one point where is it 10 units.

The first %pl with %pl[WIDTH=1] draws the expected graph. In the second %pl with %pl[WIDTH=3] the graph overshoots the desired magnitude of the impulse (by far more than 3 pixels).

Please see the annotated graphic below: https://www.dropbox.com/scl/fi/5vk4iin61argojqmkhfgq/Screenshot-2025-07-28-150549.jpg?rlkey=5zlx6vqrapgc6h4mkdjaictml&st=6cpbqh0l&dl=0

For both %pl graphs the link option is set to LINES, so this should not be related to the default “TENSION” setting.

If the parameter N (number of data points) is reduced from 200 to 20, this does not occur.

I am using the 22nd June FTN95 and DLLs.

Sorry Paul, I broke %pl again!

program test_pl
use clrwin
implicit none
integer, parameter :: n = 200  !## Change n to 20 and everthing is OK
integer :: i, iw
real*8 :: x(n), y(n)

do i = 1, n
  x(i) = i
end do
y = 0.d0
y(n/2) = 10.d0  ! Magnitude 10 impulse at one time instant

print*, 'min/max y = ', minval(y), maxval(y)

! This graph is drawn correctly
call winop@('%pl[native,n_graphs=1,x_array,link=lines,gridlines,y_min=0,y_max=12,symbol=10]')
call winop@('%pl[width=1]')   !###
call winop@('%pl[Title='This graph is correct with width=1']')
iw = winio@('%pl&',900,300,n,x,y)

! This graph has a problem
call winop@('%pl[native,n_graphs=1,x_array,link=lines,gridlines,y_min=0,y_max=12,symbol=10]')
call winop@('%pl[width=3]')   !### only difference between the configuration of the two %pl graphs
call winop@('%pl[Title='This graph is not correct with width=3']')
iw = winio@('%ff%pl&',900,300,n,x,y)
iw = winio@('')

end program test_pl
28 Jul 2025 4:18 #32246

Ken

Thank you for the feedback. I have logged this for investigation.

6 Aug 2025 11:13 #32257

Ken

This behaviour reflects a limitation of the Microsoft GDI+ library. The plot values are correct on calling an API called GdipDrawLines. I suspect that it is not a fault but simply a limitation relating to what you can draw when joining thick lines at a spike point. It may be possible to apply a clipping rectangle but it would be messy.

7 Aug 2025 12:15 #32264

Paul,

Thanks for looking at this. It is useful to know that is a Microsoft limitation rather than a Clearwin fault.

Where is does occur (not just at spikes, but sometimes at sharp edges), the alternative approach of %pl[link=user] draws the correct plot as the code below demonstrates. So a fall back methodology to overcome this already exists.

module d
use clrwin
implicit none
integer, parameter :: n = 200
real*8 :: x(n), y(n)
contains
  integer function pl_cb()
  character(len=256) cb_reason
    cb_reason = clearwin_string@('CALLBACK_REASON')
    if (cb_reason .eq. 'PLOT_ADJUST') then
      call SET_PLOT_MODE@(1)
      call SET_LINE_WIDTH@(3)
      call DRAW_POLYLINED@(x,y,n,rgb@(0,0,0))
      call DRAW_SYMBOLSD@(x,y,n,10,4,rgb@(0,0,0))
      call SET_LINE_WIDTH@(1)
      call SET_PLOT_MODE@(0)
    end if
    pl_cb = 2
  end function pl_cb
end module d

program test_pl
use d
implicit none

integer :: i, iw

do i = 1, n
  x(i) = i
end do
y = 0.d0
y(n/2) = 10.d0  ! Magnitude 10 impulse at one time instant

call winop@('%pl[native,n_graphs=1,x_array,link=user,gridlines,y_min=0,y_max=12,x_max=200]')
call winop@('%pl[Title='This graph is OK, all drawing done via the callback']')
iw = winio@('%ff%^pl&',900,300,2,dble([1,2]),dble([1,2]),pl_cb)
iw = winio@('')

end program test_pl
Please login to reply.