 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
Kenneth_Smith
Joined: 18 May 2012 Posts: 830 Location: Lanarkshire, Scotland.
|
Posted: Mon Jul 28, 2025 3:35 pm Post subject: %pl[link=lines,width=1] vs. %pl[link=lines,width=3] |
|
|
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!
Code: |
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
|
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8239 Location: Salford, UK
|
Posted: Mon Jul 28, 2025 5:18 pm Post subject: |
|
|
Ken
Thank you for the feedback. I have logged this for investigation. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8239 Location: Salford, UK
|
Posted: Wed Aug 06, 2025 12:13 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 830 Location: Lanarkshire, Scotland.
|
Posted: Thu Aug 07, 2025 1:15 pm Post subject: |
|
|
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.
Code: |
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 |
|
|
Back to top |
|
 |
|
|
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
|