Kenneth_Smith
Joined: 18 May 2012 Posts: 828 Location: Lanarkshire, Scotland.
|
Posted: Fri Jul 18, 2025 1:50 pm Post subject: %pl problem |
|
|
Paul,
One for you to look at time permitting.
Sometimes it can be useful to highlight a particular point on an curve which is plotted using %pl. This can be achieved in most cases (without resorting to annotations via the callback) by adding a second �curve� with just one point and using an appropriate symbol.
However, if the y coordinate of that particular point is zero, the symbol is not drawn. The program below demonstrates this.
Code: |
winapp
module demo_missing_symbol
use clrwin
implicit none
real*8 :: x1(1), y1(1), x2(21), y2(21)
integer :: k, kmax = 21
character(len=50) :: message = ''
contains
integer function iface()
integer :: iw, i
x2(1:kmax) = -10.d0 + dble([(i - 1, i = 1, kmax)])
y2(1:kmax) = x2(1:kmax)**2 - 49.d0
k = 1
x1(1) = x2(k)
y1(1) = y2(k)
iw = winio@('%mn[Exit]&','exit')
iw = winio@('The position of the blue symbol is changed by pressing the button%nl&')
iw = winio@('Press the button and observe the resulting plot as the symbol follows the quadratic.%nl&')
iw = winio@('%2.1ob[invisible]&')
call winop@('%pl[native,n_graphs=2,x_array,independent,width=3,margin=50,axes_pen=3]')
call winop@('%pl[colour=red,symbol=0,symbol_size=12,link=curves]')
call winop@('%pl[colour=blue,symbol=6,symbol_size=12,link=none]')
iw = winio@('%pl&',800,600,[kmax,1],x2,y2,x1,y1)
iw = winio@('%ff%tc[blue]%`rs&',message)
iw = winio@('%cb&')
iw = winio@('%^bn[Next]&',next_cb)
iw = winio@('%2nlX = %`rf%nlY = %`rf&',x1(1),y1(1))
iw = winio@('%cb&')
iw = winio@('')
iface = 1
end function iface
integer function next_cb()
integer :: iw
k = mod(k, kmax) + 1
x1(1) = x2(k)
y1(1) = y2(k)
message = ''
if (x1(1) .eq. 0.d0) message = 'X coordinate of blue symbol is exactly zero.'
if (y1(1) .eq. 0.d0) message = 'Y coordinate of blue symbol is exactly zero.'
call window_update@(message)
call window_update@(x1(1))
call window_update@(y1(1))
call simpleplot_redraw@()
next_cb = 2
end function next_cb
end module demo_missing_symbol
program p
use demo_missing_symbol
i = iface()
end program p |
|
|