Silverfrost Forums

Welcome to our forums

Set_plot_mode@(1) with draw_symbolsd@

3 Sep 2025 12:25 #32326

Paul,

Does the plot generated by the following code look as you would expect it to ?

I thought that draw_symbolsD@ would clip symbols outside the %pl[frame] with a similar behaviour to draw_polylined@?

module ex27_mod
use clrwin
implicit none
integer :: width=500, height=500
integer, parameter :: n = 21
real*8 :: x(n), y1(n), y2(n), y3(n)
contains

  integer function start()
  integer iw, i
  character(len=*),parameter :: fmt1='(22(I3,4(2X,F7.2)/))'
    x = [(i, i=-10,10,1)]
    y1 = [(x(i)**2, i = 1,n)] -5.d0
    y2 = y1 + 50.d0
    y3 = y2 + 40.d0
    write(*,fmt1) (i, x(i), y1(i), y2(i), y3(i), i = 1, n)
    iw = winio@('%fn[Arial]%ts%bg&',1.25d0,rgb@(220,220,220))
    call winop@('%pl[native,n_graphs=1,frame,x_array]')
    call winop@('%pl[link=user]')
    call winop@('%pl[margin=100]')
    call winop_flt@('%pl[x_min]',  -4.d0) ! Some points will be outside frame
    call winop_flt@('%pl[x_max]',   4.d0)
    call winop_flt@('%pl[y_min]',   0.d0)
    call winop_flt@('%pl[y_max]', 100.d0)   
    iw = winio@('%^pl',width,height,2,[0.d0,1.d0],[0.d0,1.d0],pl_cb)
    start = 2
  end function start

  integer function pl_cb()
    if (clearwin_string@('CALLBACK_REASON') .eq. 'PLOT_ADJUST') then
      call set_plot_mode@(1)
        call set_line_width@(2)
        call draw_polylined@(x,y1,n,rgb@(255,0,0))
        call draw_symbolsd@(x,y1,n,6,4,rgb@(255,0,0))
        call draw_polylined@(x,y2,n,rgb@(0,0,255))
        call draw_symbolsd@(x,y2,n,6,4,rgb@(0,0,255))
        call draw_polylined@(x,y3,n,rgb@(0,255,0))
        call draw_symbolsd@(x,y3,n,6,4,rgb@(0,255,0))
      call set_plot_mode@(0)        
    end if
    pl_cb = 2
  end function pl_cb
  
end module ex27_mod

program ex27
use ex27_mod
  i = start()
end program ex27
8 Sep 2025 5:33 #32329

Ken

Thank you for the feedback. I can see that the issue that needs fixing.

10 Sep 2025 12:32 #32331

Ken

The lack of a clipping rectangle is deliberate so that symbols can be drawn anywhere.

So I have added a mode = 2 to SET_PLOT_MODE@ and this has the desired effect of retaining the clipping rectangle for symbols.

11 Sep 2025 9:40 #32333

Thanks Paul, I understand your design basis now, and this also explains the absence of draw_symbols@ for integer pixel coordinates (which would also allow symbols to also be drawn anywhere).

Please login to reply.